#44179 [Opn->Bgs]: Ternary Operator Does Not Accept Text Logical Operators
| From: | rasmus@php.net | Date: | Wed, 20 Feb 2008 05:11:23 +0000 |
| Subject: | #44179 [Opn->Bgs]: Ternary Operator Does Not Accept Text Logical Operators | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-122487@lists.php.net to get a copy of this message | ||
ID: 44179
Updated by: rasmus@php.net
Reported By: rpanning at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Unknown/Other Function
Operating System: XP Pro SP2
PHP Version: 5.3CVS-2008-02-20 (snap)
New Comment:
Please check the operator precedence documentation. The whole point of
'and', 'or' and 'xor' is that they are right at the bottom of the
precedence table. Only the ',' operator is below them.
See: http://php.net/manual/en/language.operators.php
Previous Comments:
------------------------------------------------------------------------
[2008-02-20 04:30:35] rpanning at hotmail dot com
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 this bug report at http://bugs.php.net/?id=44179&edit=1