Edit report at https://bugs.php.net/bug.php?id=62449&edit=1

 ID:                 62449
 User updated by:    andrew at phantom dot uk dot net
 Reported by:        andrew at phantom dot uk dot net
 Summary:            Allow comma separated statements with (brace
                     omitted) if statements
-Status:             No Feedback
+Status:             Closed
 Type:               Feature/Change Request
 Package:            *General Issues
 PHP Version:        5.4.4
 Block user comment: N
 Private report:     N

 New Comment:

@johannes
Yeah, someone pointed that out to me in #phpnw right after I posted this.
@phpmpan
Assuming $foo is an instance of Exception, it would echo 'bar' then throw an 
exception, in my original though process, however someone pointed out to me 
that 
some language constructs (such as echo) already allow a comma separated list of 
arguments.

Although, in that case the comma is not immediately followed by a variable that 
can be converted to string, so I don't think that's as good a demonstration of 
the issue at hand as johannes example.

It could work if the statements were separated by say, a colon, but this is 
probably over-complicating things for a simple convenience.


Previous Comments:
------------------------------------------------------------------------
[2012-06-29 14:10:04] phpmpan at mpan dot pl

if ($foo)
  echo 'bar', throw $foo;

What should be the meaning of this code?

------------------------------------------------------------------------
[2012-06-29 14:08:20] johan...@php.net

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

Reply via email to