#48262 [Asn->Csd]: Logical Operators Manual Page Is Misleading
| From: | danielc@php.net | Date: | Thu, 27 Aug 2009 15:48:14 +0000 |
| Subject: | #48262 [Asn->Csd]: Logical Operators Manual Page Is Misleading | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-2676@lists.php.net to get a copy of this message | ||
ID: 48262
Updated by: danielc@php.net
Reported By: nomad311 at gmail dot com
-Status: Assigned
+Status: Closed
Bug Type: Documentation problem
Operating System: All
PHP Version: Irrelevant
Assigned To: danielc
New Comment:
Good point. Clarified in XML sources. Changes will show up the next
time the documentation is built.
Previous Comments:
------------------------------------------------------------------------
[2009-08-27 15:45:25] svn@php.net
Automatic comment from SVN on behalf of danielc
Revision: http://svn.php.net/viewvc/?view=revision&revision=287814
Log: clarify precedence of logical operators, bug 48262
------------------------------------------------------------------------
[2009-05-22 09:18:46] bjori@php.net
Daniel: Could you check this out?
------------------------------------------------------------------------
[2009-05-13 14:08:52] nomad311 at gmail dot com
Description:
------------
In Example #1 of the manual page for Logical Operators (
http://www.php.net/manual/en/language.operators.logical.php)
the
examples from the second and third sections are misleading. It appears
that the statements $f = false or true; and $h = true and false; are
being evaluated, then the result is stored to the variables. If this
were the case then the wrong values would have been assigned, but I now
realize (after much testing and reading) that the 'or' and 'and'
operators have less precedence than '=' and the first value is simply
being stored here. Someone else made the following post in the comments
section which is much clearer than the current documentation:
"||" has a greater precedence than "="
which has a greater one than "or"
<?php
// same as ($e = (false || true)),
// expression is true and $e ist assigned to true
$e = false || true;
// same as (($e = false) or true),
// expression is true but $e is assigned to false
$f = false or true;
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48262&edit=1