| using set_error_handler I do quite a lot of development on clients' hostings, and I've got my own error handling routine which I use in development to speed up debugging.
(reports errors direct to my webpage, insread of going to error_log and downloading that!)
But when I try it on UH hosting it doesn't pick up all errors.
It will catch and report errors like
Example 1 - misspelt pathname include("../misspeltincludes/Functions.php");
is reported as 2010-03-20 15:44:16 (GMT) 2 Warning include() [function.include]: Failed opening '../misspeltincludes/Functions.php' for inclusion (include_path='.:/php/includes:/usr/share/php:/usr/share/pear') /home/ebook/public_html/Stories/Summary.php 4
Example 2 - invalid command jjj;
is reported as 2010-03-20 15:44:16 (GMT) 8 Notice1 Use of undefined constant jjj - assumed 'jjj' /home/ebook/public_html/Stories/Summary.php 23
But when I make a mistake such as a missed out semicolon $Dot = strrpos($Story,'.')
$Story = substr($Story,0,$Dot);
Then the error handler is not called at all, and I have to go to error_log.
My clients' hostings (such as Fast Hosts) do report this kind of error, which is after all one of the most common ones.
Any reason why UH error handling works differently?
Here's my error handler // user defined error handling function
function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars) {
// timestamp for the error entry
$dt = date("Y-m-d H:i:s (T)");
// define an assoc array of error string
// in reality the only entries we should
// consider are 2,8,256,512 and 1024
$errortype = array (
1 => "Error",
2 => "Warning",
4 => "Parsing Error",
8 => "Notice",
16 => "Core Error",
32 => "Core Warning",
64 => "Compile Error",
128 => "Compile Warning",
256 => "User Error",
512 => "User Warning",
1024=> "User Notice" ,
2048=> "Notice",
4096=> "Recoverable Error"
);
// set of errors for which a var trace will be saved
$user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
$err = "<errorentry>\n";
$err .= "\t<datetime>".$dt."</datetime>\n";
$err .= "\t<errornum>".$errno."</errnumber>\n";
$err .= "\t<errortype>".$errortype[$errno]."</errortype>\n";
$err .= "\t<errormsg>".$errmsg."</errormsg>\n";
$err .= "\t<scriptname>".$filename."</scriptname>\n";
$err .= "\t<scriptlinenum>".$linenum."</scriptlinenum><br/>\n";
if (in_array($errno, $user_errors))
$err .= "\t<vartrace>".wddx_serialize_value($vars,"Variabl es")."</vartrace>\n";
$err .= "</errorentry>\n\n";
if ( ($errno <> 8) & ($errno <> 2048) ) echo $err; // for testing
// save to the error log, and e-mail me if there is a critical user error
//error_log($err, 3, "/usr/local/php4/error.log");
//if ($errno == E_USER_ERROR)
// mail("phpdev@mydomain.com","Critical User Error",$err);
//}
}
/* We will do our own error handling*/
error_reporting(E_ALL);
$old_error_handler = set_error_handler("userErrorHandler");
__________________
Malcolm
|