Robert Cummings wrote:
> On Wed, 2007-06-13 at 13:57 -0400, [EMAIL PROTECTED] wrote:
>> double pipes constitutes an "OR" operation. You can use the keyword OR as
>> well. Also, && and AND are the same as well.
>>
>> http://us.php.net/manual/en/language.operators.logical.php
>
> They aren't exactly the same. Make sure and read the order of precedence
> note. The following, for example, are not equivalent:
I knew that they we're not exactly the same due to order of precedence, but
I ran Robbert's code snippet and found that my assumptions about the outcome
incorrect!
my assumption was that '=' had lower precedence that 'and' ... somehow that
felt right,
obviously I was wrong.
it took me a few seconds to see the error of my ways :-) maybe there are other
that are confused ... maybe the output of following little snippet might help
to clarify:
<?php
$true = true;
$false = false;
$test1 = $true && $false;
$test5 = ($test2 = $true and $false);
$test3 = ($true && $false);
$test4 = ($true and $false);
var_dump($test1, $test2, $test3, $test4, $test5);
?>
thanks to Robbert for the brainteaser ;-)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php