Hi,
hier ein kleines Tool um Fehler in PHP abzufangen und zu handeln:
<?php require_once 'ErrorHandle.class.php'; error_reporting(E_ALL); ini_set("error_display",0); set_error_handler(array("ErrorHandle", "add")); ?>
<?php class ErrorHandle{ private static $errors = array(); public static $send = false; public static $errortypes_to_ignore = array(E_STRICT); public static function add($errno, $errmsg, $filename, $linenum){ ErrorHandle::$errors[] = new ErrorHandle($errno, $errmsg, $filename, $linenum); } public static function getAll(){ return ErrorHandle::$errors; } public static function toString(){ $return = ""; foreach(ErrorHandle::getAll() as $error){ $msg = $error->__toString(); if($msg != false){ $return .= $msg . "\n\n"; } } return $return; } private $errno = ""; private $errmsg = ""; private $filename = ""; private $linenum = ""; private $trace = array(); public $errortypes = Array( E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice'//, //E_RECOVERABLE_ERRROR=> 'Catchable Fatal Error' ); public function __construct($errno, $errmsg, $filename, $linenum){ $this->errno = $errno; $this->errmsg = $errmsg; $this->filename = $filename; $this->linenum = $linenum; $this->trace = debug_backtrace(); } public function __destruct(){ if(ErrorHandle::$send == true) return false; ErrorHandle::$send = true; echo ErrorHandle::toString(); } public function __toString(){ if( in_array($this->errno, ErrorHandle::$errortypes_to_ignore) ) return false; ob_start(); print_r($this->trace); $trace_ret = ob_get_contents(); ob_end_clean(); return "Errortype:\t" . $this->errortypes[$this->errno] . "\n" . "Filename:\t" . $this->filename . "\n" . "Linenumber\t" . $this->linenum . "\n" . "Errormsg\t" . $this->errmsg . "\n" . "\nTrace: \n" . $trace_ret; } } ?>
Kleiner Tipp: Leichte Erweiterung und Einbettung in HTML möglich


