Hi ,
I'm trying to get php to report parse errors to an email and redirect the page, but when there is a parse error this following code doesn't seem to recognize the parse error and the page redirects to the php default error page.
<?
// Decide what errors to report:
error_reporting (E_ERROR | E_WARNING | E_NOTICE | E_PARSE);
// Webmaster email and error page url:
$Wmemail = 'shane@gnative.com';
$ErrorPage = 'http://www.gnative.com/verse2/error.html';
// This function will check the error type:
function MailErrorHandler($errno, $errstr, $errfile='?', $errline= '?')
{
global $Wmemail, $ErrorPage;
if (($errno & error_reporting()) == 0)
return;
$err = '';
switch($errno) {
case E_ERROR: $err = 'FATAL'; break;
case E_WARNING: $err = 'ERROR'; break;
case E_PARSE: $err = 'ERROR'; break;
case E_NOTICE: return;
}
// Send the error details via email:
mail($Wmemail,
"PHP: $errfile, $errline",
"$errfile, Line $errline\n$err($errno)\n$errstr");
// Redirect to the error page:
print '<META HTTP-EQUIV="Refresh" CONTENT="0;url='.$ErrorPage.'">';
die();
}
set_error_handler('MailErrorHandler');
?>