php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #48262 Logical Operators Manual Page Is Misleading
Submitted: 2009-05-13 14:08 UTC Modified: 2009-08-27 15:48 UTC
From: nomad311 at gmail dot com Assigned: danielc (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
 [2009-05-13 14:08 UTC] 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;
?>



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-22 09:18 UTC] bjori@php.net
Daniel: Could you check this out?
 [2009-08-27 15:45 UTC] 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-08-27 15:48 UTC] danielc@php.net
Good point.  Clarified in XML sources.  Changes will show up the next time the documentation is built.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Jun 16 10:00:01 2026 UTC