#50372 [Opn->Bgs]: Ternary statements are not identical
| From: | rquadling@php.net | Date: | Thu, 03 Dec 2009 12:52:42 +0000 |
| Subject: | #50372 [Opn->Bgs]: Ternary statements are not identical | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-3393@lists.php.net to get a copy of this message | ||
ID: 50372
Updated by: rquadling@php.net
Reported By: jakeophobia at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
The () in the second version are redundant and are only there to
emphasize the left-to-right expression evaluation. The output of both
versions is the same, 't'.
Previous Comments:
------------------------------------------------------------------------
[2009-12-03 12:13:15] jakeophobia at gmail dot com
Description:
------------
On page:
http://www.php.net/manual/en/language.operators.comparison.php
In 'Example #3 Non-obvious Ternary Behaviour'
The two statements are not 'identical'.
The second ternary statment has parenthesis on 'false'
Expected result:
----------------
...
echo (true?'true':false?'t':'f');
...the following is a more obvious version of the same code as
above...
echo ((true ? 'true' : false) ? 't' : 'f');
...
Actual result:
--------------
...
echo (true?'true':false?'t':'f');
...the following is a more obvious version of the same code as
above...
echo ((true ? 'true' : 'false') ? 't' : 'f');
...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50372&edit=1