note 11026 deleted from features.error-handling by victor

From: Date: Wed, 09 Oct 2002 15:28:57 +0000
Subject: note 11026 deleted from features.error-handling by victor
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-37849@lists.php.net to get a copy of this message
This is an error logging file i have written: <?php error_reporting(0); $old_error_handler = set_error_handler("userErrorHandler"); function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars) { $time=date("d M Y H:i:s"); // Get the error type from the error number $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"); $errlevel=$errortype[$errno]; //Write error to log file (CSV format) $errfile=fopen("errors.csv","a"); fputs($errfile,"\"$time\",\"$filename: $linenum\",\"($errlevel) $errmsg\"\r\n"); fclose($errfile); if($errno!=2 && $errno!=8) //Terminate script if fatal error { die("A fatal error has occured. Script execution has been aborted"); } } ?> Now all you have to do is include() this error file, and you will have error handling on all pages

« previous php.notes (#37849) next »