I can catch a fatal error with register_shutdown_function('shutdown')
function shutdown(){
$error = error_get_last();
$result['message'] = $error['message'];
}
and I have an echo json_encode($result);
Unfortunately this echo json_encode
shows nothing because json is not updated with the message of the fatal error.
What can I do to fix this?
Why move one array to another array and then echo the second array.
Why not just do this
Or even this
Apart form the use of an unnecessary array, this will give you all the information available from
get_last_error()
Of course it could be that the
error_get_last()
information is just not available at this late stage in the shutdown process. If this is the case then you can pass extra parameters to the shutdown function and this may be what you need to do.and
EDITED:
First I have added
error_reporting(~E_ERROR); // don't report fatal errors
The first one worked for me I mean
For my needs I wrote: