Re: A serious bug? "or" operator gives out diffferent results depending on order of operands
| From: | Rory Browne | Date: | Tue, 28 Dec 2004 22:07:34 +0000 |
| Subject: | Re: A serious bug? "or" operator gives out diffferent results depending on order of operands | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-205276@lists.php.net to get a copy of this message | ||
> $a = $b ^^ $c
You sure? It didn't work for me, and it isn't listed in the PHP manual.
I used:
<?php
var_dump(1 ^^ 0);
var_dump(0 ^^ 1);
var_dump(0 ^^ 0);
var_dump(1 ^^ 1);
?>
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 ^ !$c; since xor
depends exclusively on both sides being different to each other.
> > 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 the right is when using the xor operator, since there is
> > no equivlent above the = operator.
>
> $a = $b ^^ $c;
>
> --
> Using M2, Opera's revolutionary e-mail client:
> http://www.opera.com/m2/
>
> http://www.smempire.org
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>