3 ms·
None of those snippets contain a ternary operator. ?? is the Null Coalescing Operator[1] ?-> is the nullsafe operator[2] [1]: https://www.php.net/manual/en/l
by jorams 4y ago
None of those snippets contain a ternary operator.
?? is the Null Coalescing Operator[1]
?-> is the nullsafe operator[2]
[1]: https://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.coalesce https://www.php.net/manual/en/language.operators.comparison....
[2]: https://www.php.net/manual/en/language.oop5.basic.php#language.oop5.basic.nullsafe https://www.php.net/manual/en/language.oop5.basic.php#langua...
- firasd 4y agoOh my mistake. Still stuff like 'return a || b' is the kind of thing I see in JS way more than in PHP codebases
- deergomoo 4y agoProbably because the Boolean operators in JS return the left or right side of the expression, rather than a Boolean. It was an okay-ish way to get a default/fallback value before JS got a proper coalescing operator.