Hi ,
I'v ebeen trying for hours to record parse errors with the following script and log these. But it seems like parsing errors are made
before the script is run, when the script is compiled , then making this script redundant ( which at the moment is just sent off to an email and displays an error page).
Is there a way to capture parse errors and possibly log this into a file like core php does anyway ?
would love you long time if someone could help
<?
// 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');
?>