I can use set_error_handler()
to catch most PHP errors, but it doesn\'t work for fatal (E_ERROR
) errors, such as calling a function that doesn\'t e
I developed a way to catch all error types in PHP (almost all)! I have no sure about E_CORE_ERROR (I think will not works only for that error)! But, for other fatal errors (E_ERROR, E_PARSE, E_COMPILE...) works fine using only one error handler function! There goes my solution:
Put this following code on your main file (index.php):
' . $typestr .
': ' . $errstr .
' in ' . $errfile .
' on line ' . $errline .
'
';
if(($errno & E_FATAL) && ENV === 'production'){
header('Location: 500.html');
header('Status: 500 Internal Server Error');
}
if(!($errno & ERROR_REPORTING))
return;
if(DISPLAY_ERRORS)
printf('%s', $message);
//Logging error on php file error log...
if(LOG_ERRORS)
error_log(strip_tags($message), 0);
}
ob_start();
@include 'content.php';
ob_end_flush();
?>