#44179 [NEW]: Ternary Operator Does Not Accept Text Logical Operators

From: Date: Wed, 20 Feb 2008 04:30:35 +0000
Subject: #44179 [NEW]: Ternary Operator Does Not Accept Text Logical Operators
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-122486@lists.php.net to get a copy of this message
From: rpanning at hotmail dot com Operating system: XP Pro SP2 PHP version: 5.3CVS-2008-02-20 (snap) PHP Bug Type: Unknown/Other Function Bug description: Ternary Operator Does Not Accept Text Logical Operators Description: ------------ It seems that the ternary conditional operator does not accept the text logical operators (and, or, xor). They assign int 1 instead of the other expressions. The xor is even odder in that if the TRUE comes before the xor, it will not assign anything. If it is the reverse, it will assign int 1. Tested this with both PHP 5.2.5 and the latest snap of 5.3. Don't believe this is the expected behavior. Reproduce code: --------------- $and = (TRUE and TRUE ? 'True' : 'False'); $or = (FALSE or TRUE ? 'True' : 'False'); $xor = (TRUE xor FALSE ? 'True' : 'False'); $aa = (TRUE && TRUE ? 'True' : 'False'); $ll = (TRUE || FALSE ? 'True' : 'False'); print('and = ' . $and . "<br>\r\n"); print('or = ' . $or . "<br>\r\n"); print('xor = ' . $xor . "<br>\r\n"); print('&& = ' . $aa . "<br>\r\n"); print('|| = ' . $ll . "<br>\r\n"); Expected result: ---------------- and = True<br> or = True<br> xor = True<br> && = True<br> || = True<br> Actual result: -------------- and = 1<br> or = 1<br> xor = <br> && = True<br> || = True<br> -- Edit bug report at http://bugs.php.net/?id=44179&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44179&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44179&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44179&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44179&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44179&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44179&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44179&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44179&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44179&r=support Expected behavior: http://bugs.php.net/fix.php?id=44179&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44179&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44179&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44179&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44179&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44179&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44179&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44179&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44179&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44179&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44179&r=mysqlcfg

« previous php.bugs (#122486) next »