#30689 [NEW]: logical operators not working as expected

From: Date: Thu, 04 Nov 2004 17:54:16 +0000
Subject: #30689 [NEW]: logical operators not working as expected
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-68709@lists.php.net to get a copy of this message
From: ioan dot nicu at ines dot ro Operating system: Linux PHP version: 4CVS-2004-11-04 (stable) PHP Bug Type: Zend Engine 2 problem Bug description: logical operators not working as expected Description: ------------ The logical operators 'and', 'or', 'xor' have unexpected results. The bug doesn't occur when using C-style logical operators ( ||, &&, ^^). From the php manual (Logical Operators Section): http://www.php.net/manual/en/language.operators.logical.php Example | Name | Result -------------------------------------------------- $a and $b | And | TRUE if both $a and $b are TRUE. $a or $b | Or | TRUE if either $a or $b is TRUE. $a xor $b | Xor | TRUE if either $a or $b is TRUE, but not both. This bug is reproducible on the latest stable snapshot from cvs. Reproduce code: --------------- <? $a1 = false or true; $a2 = true or false; $b1 = true or false; $b2 = false and true; $c = true xor true; echo("false or true = ");var_dump($a1); echo("true or false = ");var_dump($a2); echo("true and false = ");var_dump($b1); echo("false and true = ");var_dump($b2); echo("true xor true = ");var_dump($c); ?> Expected result: ---------------- false or true = bool(true) true or false = bool(true) true and false = bool(false) false and true = bool(false) true xor true = bool(false) Actual result: -------------- false or true = bool(false) true or false = bool(true) true and false = bool(true) false and true = bool(false) true xor true = bool(true) -- Edit bug report at http://bugs.php.net/?id=30689&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30689&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30689&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30689&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30689&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30689&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30689&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30689&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30689&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30689&r=support Expected behavior: http://bugs.php.net/fix.php?id=30689&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30689&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30689&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30689&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30689&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30689&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30689&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30689&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30689&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30689&r=mysqlcfg

« previous php.bugs (#68709) next »