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

2004-12-28 Thread Rory Browne
> $a = $b ^^ $c You sure? It didn't work for me, and it isn't listed in the PHP manual. I used: to test it and got a syntax error. I suppose you could use the bitwise one as a bit of a hack, so long as you 'boolean-ised' both arguments first. eg $a = (!!$b) ^ (!!$c); // or even $a = !$b ^

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

2004-12-27 Thread Thomas Goyne
On Mon, 27 Dec 2004 21:19:39 +, Rory Browne <[EMAIL PROTECTED]> wrote: Generally however there is no need to parentisize everything to the right of the assignment operator(=), since besides 'and', 'or', 'xor', and the comma operator. The only time I see the need to parentisize everything to

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

2004-12-27 Thread Rory Browne
I think what this highlights is that the or operator isn't supposed to be used in that way. It is simply supposed to be used to add a back door to failed function calls. ie mysql_connect(args) or die("mysql connection failed") If you want to return true when either $a or $b is true, then use ||. e

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

2004-12-27 Thread Jose M.Herrera
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Rory Browne wrote: | I think what Jose is trying to say, is that because 'or' has a lower | precidence than =, you are interpreting the expression wrong. Yes, I was trying to say that. The () are very important when you need to use OR, AND, ||, &&, etc.

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

2004-12-26 Thread Richard Lynch
Bogdan Ribic wrote: > $b1 = is_null($x) or ($y > 5); > $b2 = ($y > 5) or is_null($x); To add to what has been posted already: If 'or' isn't what you want '||' probably *IS* what you want. Watch out though -- Sometimes even the precedence of '||' isn't as high/low as I hoped, and if in doubt, use

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

2004-12-26 Thread Rory Browne
I think what Jose is trying to say, is that because 'or' has a lower precidence than =, you are interpreting the expression wrong. $b1 = is_null($x) or ($y > 5); is the same as ($b1 = is_null($x)) or ($y > 5) This assigns the value of is_null($x) to $b1, regardless of the result of ($y > 5). It'

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

2004-12-24 Thread Jose M.Herrera
-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

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

2004-12-23 Thread Comex
Uh.. $y is > 5. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

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

2004-12-23 Thread Rasmus Lerdorf
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); 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 th

[PHP] A serious bug? "or" operator gives out diffferent results depending on order of operands

2004-12-23 Thread Bogdan Ribic
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 du