#48262 [Opn->Asn]: Logical Operators Manual Page Is Misleading

From: Date: Fri, 22 May 2009 09:18:47 +0000
Subject: #48262 [Opn->Asn]: Logical Operators Manual Page Is Misleading
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2291@lists.php.net to get a copy of this message
ID: 48262 Updated by: bjori@php.net Reported By: nomad311 at gmail dot com -Status: Open +Status: Assigned Bug Type: Documentation problem Operating System: All PHP Version: Irrelevant -Assigned To: +Assigned To: danielc New Comment: Daniel: Could you check this out? Previous Comments: ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#2291) next »