Edit report at https://bugs.php.net/bug.php?id=62449&edit=1
ID: 62449
Comment by: phpmpan at mpan dot pl
Reported by: andrew at phantom dot uk dot net
Summary: Allow comma separated statements with (brace
omitted) if statements
Status: No Feedback
Type: Feature/Change Request
Package: *General Issues
PHP Version: 5.4.4
Block user comment: N
Private report: N
New Comment:
if ($foo)
echo 'bar', throw $foo;
What should be the meaning of this code?
Previous Comments:
------------------------------------------------------------------------
[2012-06-29 14:08:20] [email protected]
This leads to too many conflicts. For instance what should this code do:
if (condition()) echo foo(), bar();
right now it prints the returned values from foo() and bar(). This can't be
easily distinguished from your syntax. There are other similar cases. Such
special case syntax also makes the language more complex with more special
cases to mind.
------------------------------------------------------------------------
[2012-06-29 13:38:26] andrew at phantom dot uk dot net
Description:
------------
Allow statements to be separated by commas in single line if statements (when
omitting the braces)
Test script:
---------------
if ( isset($_GET['take_me_there']) )
header('location: /you_are_here.php'), exit;
Expected result:
----------------
The client would be redirected to www.yoursite.com/you_are_here.php and the
script would terminate execution.
Actual result:
--------------
Parse error: syntax error, unexpected ',' in /opt/lampp/htdocs/test.php on line
2
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62449&edit=1