#48262 [NEW]: Logical Operators Manual Page Is Misleading

From: Date: Wed, 13 May 2009 14:08:52 +0000
Subject: #48262 [NEW]: Logical Operators Manual Page Is Misleading
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2249@lists.php.net to get a copy of this message
From: nomad311 at gmail dot com Operating system: All PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: Logical Operators Manual Page Is Misleading 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 bug report at http://bugs.php.net/?id=48262&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48262&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48262&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48262&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48262&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48262&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48262&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48262&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48262&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48262&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48262&r=support Expected behavior: http://bugs.php.net/fix.php?id=48262&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48262&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48262&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48262&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48262&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48262&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48262&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48262&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48262&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48262&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48262&r=mysqlcfg

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