Here's a little test script:
-------------------- $x = 2; $y = 10;
$b1 = is_null($x) or ($y > 5); $b2 = ($y > 5) or is_null($x);
var_dump($b1); var_dump($b2); --------------------
Obviously, it should be false for both $b1 and $b2, but the output is:
bool(false) bool(true)
Is this a bug? I tried dumping values of two expressions, they are both boolean and correct value. Tried assigning values to two temp vars and then or-ing these two, and that gave correct results.
I really cannot see what am I doing wrong. Tried this with php 4.3.2 and 4.3.9, and I get these weird results both times. Maybe I should herd cattle or something :)
The whole point of OR is that it is a very low precedence operator. Think of it as being at the bottom of the precedence table (it isn't quite, ',' is lower) so you can do:
$a = b() + $c / $d OR echo "false";
That is, do everything before the OR first, then see what that evaluates to before applying the OR. This wouldn't work if it took precedence over anything in the rest of the expression.
-Rasmus
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php