Re: A serious bug? "or" operator gives out diffferent results depending on order of operands
| From: | Jose M.Herrera | Date: | Fri, 24 Dec 2004 19:47:42 +0000 |
| Subject: | Re: A serious bug? "or" operator gives out diffferent results depending on order of operands | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-205153@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Bogdan Ribic wrote:
| Here's a little test script:
|
| --------------------
| $x = 2;
| $y = 10;
|
| $b1 = is_null($x) or ($y > 5);
| $b2 = ($y > 5) or is_null($x);
Yes, of course.
Your code or example, is just like:
( $b1 = is_null($x) ) or ( $y > 5 ) ;
( $b2 = ($y > 5) ) or is_null($x) ;
The ">" has more precedence than "=", "or" it has a very low precedence.
Then, $b1 = false and $b2 = True... that's ok! :P
You example, must have been:
$b1 = ( ( is_null($x) ) or ( $y > 5 ) ); $b2 = ( ( $y > 5 ) or ( is_null($x) ) );I this example the value of $b1 is all between the parenthesis (explicitly). Bye! - -- Jose Miguel Herrera M. - User #246070 counter.li.org Est.Ing.Civil Informatica - UTFSM Valparaiso, Chile - http://www.inf.utfsm.cl/~jherrera -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBzHJdl/j2VHFHn8wRArZdAKCJbv8W54vlpeinK1hMF3xEttjuiACeIIUs 63OX2bn+h9zLUDHhSvSTr/M= =3vfi -----END PGP SIGNATURE-----