I am trying to use the PHP error_get_last()
function, but my question goes more to general handling of arrays in PHP.
error_get_last()
returns an array, but I only want the 'message' element from it.
So this works:
$ErrData = error_get_last();
$ErrMsg = $ErrData['message'];
but this is a syntax error:
$ErrMsg = error_get_last()['message'];
Can someone explain why, if error_get_last()
returns an array, the elements cannot be referenced directly?
Surely I don't have to create unwanted temporary array variables whenever I want to access elements like this?