#30825 [Opn->Fbk]: Ternary operator (?:) goes wrong

From: Date: Thu, 18 Nov 2004 15:03:34 +0000
Subject: #30825 [Opn->Fbk]: Ternary operator (?:) goes wrong
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-69214@lists.php.net to get a copy of this message
ID: 30825 Updated by: tony2001@php.net Reported By: Arne dot Heizmann at csr dot com -Status: Open +Status: Feedback Bug Type: Unknown/Other Function Operating System: Windows XP PHP Version: 4.3.9 New Comment: Could tell me how do you think it should work: like this echo (true ? "Yes" : false) ? "No" : "No2"; or like this echo true ? "Yes" : (false ? "No" : "No2"); and why ? Previous Comments: ------------------------------------------------------------------------ [2004-11-18 15:40:59] Arne dot Heizmann at csr dot com Description: ------------ The ternary conditional operator (?:) goes wrong when nested two levels deep. When adding parentheses, the bug disappears, even when the parentheses are redundant and shouldn't make any difference. Reproduce code: --------------- echo true ? "Yes" : false ? "No" : "No2"; Expected result: ---------------- "Yes" Actual result: -------------- "No" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30825&edit=1

« previous php.bugs (#69214) next »