Re:Higher Order PHP
by IsaacSchlueter on Friday February 06, 2009 @07:48PM
(#470645)
Ars, the point is that $var = $tom || 'ed'; is much less verbose than the alternatives.
More generally, it's just strange to me that || and && don't operate the same in PHP as they do in every other C-style language. Neither does the ternary if, for that matter.
PHP 5.3 (and/or 6, I forget) gives us
$var = $tom ?: 'ed';
Do you mean:
If so, you can also do: If you don't want to calculate $tom twice.