ID: 25356 Updated by: [EMAIL PROTECTED] Reported By: matschek at gmx dot de -Status: Verified +Status: Closed Bug Type: Documentation problem Operating System: Irrelevant PHP Version: Irrelevant New Comment:
This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Removed note. Previous Comments: ------------------------------------------------------------------------ [2003-09-02 08:24:49] [EMAIL PROTECTED] To get the correct result do this: echo $c1 ? 1 : ($c2 ? 2 : 3); Isn't that much readable too? :) Anyway, that note about ternary being same as in C is wrong. ------------------------------------------------------------------------ [2003-09-02 06:30:51] matschek at gmx dot de Description: ------------ The documentation says in the section Comparison Operators: "Another conditional operator is the "?:" (or ternary) operator, which operates as in C and many other languages" This is not true, because in C and other languages the ternary-operator is parsed/compiled from left to right, and therefore cases other results. The included code returns "1" in C and JavaScript, for example, but "2" in PHP Reproduce code: --------------- $c1=true; $c2=false; echo $c1 ? 1 : $c2 ? 2 : 3; Expected result: ---------------- 1 Actual result: -------------- 2 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25356&edit=1
