> $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 ^
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
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
-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.
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
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'
-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
Uh.. $y is > 5.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
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
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
10 matches
Mail list logo