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
.