#50372 [Bgs]: Ternary statements are not identical

From: Date: Thu, 03 Dec 2009 21:25:26 +0000
Subject: #50372 [Bgs]: Ternary statements are not identical
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3400@lists.php.net to get a copy of this message
ID: 50372 User updated by: jakeophobia at gmail dot com Reported By: jakeophobia at gmail dot com Status: Bogus Bug Type: Documentation problem PHP Version: Irrelevant New Comment: Oops, I meant single quotes. Take a look at false vs. 'false' Previous Comments: ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#3400) next »