Why is it that in PHP 5.3.8
:
$obj->foo()['bar']; // syntax error
$obj->foo()->['bar']; // valid
But in PHP 5.4.9
it's reverse:
$obj->foo()['bar']; // valid
$obj->foo()->['bar'] // syntax error
Why is it that in PHP 5.3.8
:
$obj->foo()['bar']; // syntax error
$obj->foo()->['bar']; // valid
But in PHP 5.4.9
it's reverse:
$obj->foo()['bar']; // valid
$obj->foo()->['bar'] // syntax error
$obj->foo()['bar'];
is valid in PHP >= 5.4.0
$obj->foo()->['bar']
is not valid in any version even if you add the required ;
So in versions before 5.4.0 you will get a parse error on the first line that will stop execution and not show the parse error on the next line.
In versions 5.4.0 and greater the first line works but you get a parse error on the second. So if you reverse them, you will always get the parse error for $obj->foo()->['bar']
in any version.