Is the PHP ternary operator broken?
This C code does what I expect:
It prints the number 2.
int x = 3;
int y = (x<3)?1:(x<4)?2:(x<6)?3:4;
This PHP code does not:
Instead I get 3
$x = 3;
$y = ($x<3)?1:($x<4)?2:($x<6)?3:4;
It only seems to evaluate the last expression. Anyone know if this would be a bug, or if there is a reason for this?
I dont like it :(
Edit: found the answer, http://bugs.php.net/bug.php?id=25356. Guess I should have searched first...