Bug #75777 [Com]: Shorthand if/else parsing problem
| From: | haseeb dot basil at gmail dot com | Date: | Mon, 08 Jan 2018 09:13:10 +0000 |
| Subject: | Bug #75777 [Com]: Shorthand if/else parsing problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213421@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75777&edit=1
ID: 75777
Comment by: haseeb dot basil at gmail dot com
Reported by: kongocode at gmail dot com
Summary: Shorthand if/else parsing problem
Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: Windows 10
PHP Version: 7.0.27
Block user comment: N
Private report: N
New Comment:
It does provide valid output, when 2nd part of the statement is enclosed in brackets:
<?php
echo (true ? "a" : ((false) ? "b" : "c"));
//Output: a
?>
Previous Comments:
------------------------------------------------------------------------
[2018-01-08 09:12:25] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
https://php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary
------------------------------------------------------------------------
[2018-01-08 08:59:11] kongocode at gmail dot com
Description:
------------
Hello, today I discovered bug (I think) which occurs in parsing shorthand ifs. It happens when we
use shorthand if in shorthand if without braces.
Test script:
---------------
<?php
echo (true ? "a" : (false) ? "b" : "c");
//Output is:
b instead of a.
//Java and C# tells it's a
?>
Expected result:
----------------
to see letter a
Actual result:
--------------
b
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75777&edit=1