#50372 [Asn->Csd]: Ternary statements are not identical
| From: | rquadling@php.net | Date: | Fri, 04 Dec 2009 09:19:51 +0000 |
| Subject: | #50372 [Asn->Csd]: Ternary statements are not identical | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-3404@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: Assigned
+Status: Closed
Bug Type: Documentation problem
PHP Version: Irrelevant
Assigned To: rquadling
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.
Previous Comments:
------------------------------------------------------------------------
[2009-12-04 09:19:37] svn@php.net
Automatic comment from SVN on behalf of rquadling
Revision: http://svn.php.net/viewvc/?view=revision&revision=291695
Log: Make examples consistent. Fix #50372
------------------------------------------------------------------------
[2009-12-04 09:18:41] rquadling@php.net
Aha! I see.
Actually, false / 'false' could be anything.
echo (true?'true':99?'t':'f');
echo (true?'true':foo?'t':'f');
echo (true?'true':null?'t':'f');
echo (true?'true':false?'t':'f');
echo (true?'true':'false'?'t':'f');
all output 't' as the result do to the left-to-right evaluation.
------------------------------------------------------------------------
[2009-12-03 21:25:25] jakeophobia at gmail dot com
Oops, I meant single quotes. Take a look at false vs. 'false'
------------------------------------------------------------------------
[2009-12-03 12:52:42] rquadling@php.net
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'.
------------------------------------------------------------------------
[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