|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-08-04 17:04 UTC] jeroen@php.net
[2001-08-04 17:21 UTC] jeroen@php.net
[2001-10-13 13:41 UTC] sterling@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 22:00:01 2025 UTC |
The following emits 'two' rather than 'one' as one would expect. $a = 1; $b = 2; echo (($a == 1) ? 'one' : ($b == 2) ? 'two' : 'unknown'); Apologies if for PHP this unusual behaviour actually is as expected, but being counter-intuituve, and of course inconsistent from other languages with a ?: operator, this is an undesirable result. In 'C', the following of course outputs 'one' #include <stdio.h> int main() { int a = 1, b = 2; puts((a == 1) ? "one" : (b == 2) ? "two" : "unknown"); return 0; }