|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-02-20 05:11 UTC] rasmus@php.net
[2008-02-20 14:03 UTC] rpanning at hotmail dot com
[2008-02-20 17:44 UTC] rasmus@php.net
[2008-02-20 20:17 UTC] rpanning at hotmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 11:00:01 2025 UTC |
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>