Voting

: min(seven, four)?
(Example: nine)

The Note You're Voting On

Marcelius
16 years ago
Another way to catch PHP's fatal errors:

<?php
error_reporting
(E_ALL);
ini_set('display_errors', 0);

function
shutdown(){
$isError = false;
if (
$error = error_get_last()){
switch(
$error['type']){
case
E_ERROR:
case
E_CORE_ERROR:
case
E_COMPILE_ERROR:
case
E_USER_ERROR:
$isError = true;
break;
}
}

if (
$isError){
echo
"Script execution halted ({$error['message']})";
} else {
echo
"Script completed";
}
}

register_shutdown_function('shutdown');
?>

Note that this will only catch runtime errors. So calling a method in a non existing class, or declaring a function twice does not trigger the shutdown handler.

<< Back to user notes page

To Top