note 73786 deleted from language.operators.logical by colder
| From: | colder@php.net | Date: | Fri, 20 Apr 2007 15:35:04 +0000 |
| Subject: | note 73786 deleted from language.operators.logical by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125686@lists.php.net to get a copy of this message | ||
Note Submitter: g dot vieri AT gmail dot com
----
seems that are more subtle reasons for two different variations of "and" and
"or" operators.
see the example:
<?php
$a="test";
$b=1;
$res= $a || $b;
echo $res."\n\n";
$a="test";
$b=1;
$res= $a or $b;
echo $res."\n\n";
?>
If the difference between the or and || operator is only the precedence we can expect the same
output from both the "echo" instructions.
This is the result:
1
test
So seems that the '||' operator convert in "bool" the result of logical
expression. This is not the same behaviour of the 'or' operator.
You can verify from yourself adding var_dump() before the echo.