ID: 30689 Updated by: [EMAIL PROTECTED] Reported By: ioan dot nicu at ines dot ro -Status: Open +Status: Bogus Bug Type: Zend Engine 2 problem Operating System: Linux PHP Version: 4CVS-2004-11-04 (stable) New Comment:
No bug here, the = operator has a higher precedence than and, or and xor so you'll have to use parenthesis. See: http://www.php.net/manual/en/language.operators.php#language.operators.precedence Previous Comments: ------------------------------------------------------------------------ [2004-11-04 18:54:14] ioan dot nicu at ines dot ro 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 this bug report at http://bugs.php.net/?id=30689&edit=1