Re:Higher Order PHP
by bprater on Friday February 06, 2009 @02:53PM
(#470237)
Some days, all I wish is that PHP had a shortcut assignment operator:
[ Parent
| on HN ]
What is that intended to mean?
Do you mean:
$var = $tom ? $tom : 'ed';
If so, you can also do: $var = $tom or $var = 'ed';
If you don't want to calculate $tom twice.
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';