News for hackers. Stuff that matters.
Re:Higher Order PHP by ars on Friday February 06, 2009 @03:55PM (#470345)
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.

Re:Higher Order PHP by salathe on Saturday February 07, 2009 @07:26AM (#471082)
PHP 5.3 (and/or 6, I forget) gives us

    $var = $tom ?: 'ed';
Re:Higher Order PHP by compay on Saturday February 07, 2009 @11:04PM (#471804)
I love how Groovy refers to that as the "Elvis" operator.