In PHP, is there a more concise way of writing $x ? $x : $y? Repeating $x feels unnecessary, especially if it’s a longer expression. It’s not very important how false values are handled, as long as $y is returned when $x is undefined or null.
In Perl, I’d use $x // $y or $x || $y.
Yes, but only if you have PHP 5.3+ installed. You can simply miss out the middle part:
See the documentation in the manual for comparison operators.