silly php question... why cant i do this?
echo Auth::getFullUser()[ 'country' ];
instead you have to do this
$user = Auth::getFullUser();
echo $user[ 'country' ];
The syntax just doesn't allow it unfortunately. AFAIK there was at one time intention to put that syntax in PHP6, but it has been dropped. | |||||
|
PHP grammar only allows subscript notation (i.e. | |||
|
Poor language/interpreter design. Same reason you can't do "functionname"() and functions are case insensitive. | |||||||||||||||||
|
echo ( Auth::getFullUser() )[ 'country' ];
– Jacob Relkin May 20 '10 at 15:24