> From: Bogdan Ribic <[EMAIL PROTECTED]>

> 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.

= has a higher precedence than OR and OR is not the same as ||

http://www.php.net/manual/en/language.operators.php#language.operators.precedence

So you should use

$b1 = is_null($x) || ($y > 5);

---John Holmes...

UCCASS - PHP Survey System
http://www.bigredspark.com/survey.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to