I am using the following script from nettuts:
// Our custom error handler
function error_engine($number, $message, $file, $line, $vars)
{
$email = "
<p>An error ($number) occurred on line
<strong>$line</strong> and in the <strong>file: $file.</strong>
<p> $message </p>";
$email .= "<pre>" . print_r($vars, 1) . "</pre>";
$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Email the error to someone...
error_log($email, 1, 'example@example.com', $headers);
if ( ($number !== E_NOTICE) && ($number < 2048) ) {
die("There was an error. Please try again later.");
}
}
// We should use our custom function to handle errors.
set_error_handler('error_engine');
It works fine for notices and warnings and such, but when I purposely break my script, say by changing “mysqli_connect” to “mysqy_connct” I get the fatal error printing out on the screen and no email!
Is an error like that beyond the scope of this type of error logging/reporting?
What am I doing wrong?
It’s listed in the documentation: