note 73786 added to language.operators.logical
| From: | gdotvieriATgmaildotcom at osu1 dot php dot net | Date: | Sat, 10 Mar 2007 09:19:26 +0000 |
| Subject: | note 73786 added to language.operators.logical | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124293@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 213.92.11.19
Probable Submitter: 85.18.136.70
----
Manual Page -- http://www.php.net/manual/en/language.operators.logical.php
Edit -- https://master.php.net/note/edit/73786
Del: integrated -- https://master.php.net/note/delete/73786/integrated
Del: useless -- https://master.php.net/note/delete/73786/useless
Del: bad code -- https://master.php.net/note/delete/73786/bad+code
Del: spam -- https://master.php.net/note/delete/73786/spam
Del: non-english -- https://master.php.net/note/delete/73786/non-english
Del: in docs -- https://master.php.net/note/delete/73786/in+docs
Del: other reasons-- https://master.php.net/note/delete/73786
Reject -- https://master.php.net/note/reject/73786
Search -- https://master.php.net/manage/user-notes.php