4 ms·
Some days, all I wish is that PHP had a shortcut assignment operator: $var = $tom || 'ed';
by bprater 18y ago
Some days, all I wish is that PHP had a shortcut assignment operator:
$var = $tom || 'ed';
- ars 18y agoWhat 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.
- IsaacSchlueter 18y agoArs, 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.