silly php question... why cant i do this?
echo Auth::getFullUser()[ 'country' ];
instead you have to do this
$user = Auth::getFullUser();
echo $user[ 'country' ];
A function can return a value using the return statement in conjunction with a value or object. return stops the execution of the function and sends the value back to the calling code. You can return more than one value from a function using return array(1,2,3,4).
The count() function returns the number of elements in an array.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With