Re: A serious bug? "or" operator gives out diffferent results depending on order of operands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux