From PHP 5.4, I can call an element of a function returned array, like so: func()['el']
.
I'm running PHP 5.6 and test the following (simplified) code:
Works
$decoded = json_decode($content, true)['foo'];
Doesn't Work
($decoded = json_decode($content, true))['foo']; // syntax error ['
I don't understand why I cannot assign json_decode($content, true)
to $decoded
and call the element foo
immediately. This works fine in php 7
Why this is Interesting?
My PhpStorm 2017.2.1, with applied php 5.6 DOESN'T detect this code as available in PHP 7 only!