hi ,
i wrote a function to handle php errors in my script … but i have problem , i’m trying to trace line & file name in every errors occure , to determine actually where is the error cause …
i used exception class in my function then used getTrace method to trace details of source error …
but my problem that it give me long array , and the array include really source of error details such as file path which contain error and line of error …
so my question is how to extract actually details for every error occure from this long array …
my error handler function is :
public static function error($errno, $errstr, $errfile, $errline)
{
$exception = new ErrorException();
$err = $exception->getTrace();
switch($errno)
{
case E_ERROR:
case E_USER_ERROR:
$type = 'Fatal Error';
$message = self::write_log($type,$errstr,$err['1']['file'],$err['1']['line'],$errfile,true);
self::msg('php',$message);
break;
case E_WARNING:
case E_USER_WARNING:
$type = 'Warning';
self::write_log($type,$errstr,$err['0']['file'],$err['0']['line'],$errfile);
break;
case E_NOTICE:
case E_STRICT:
case E_USER_NOTICE:
$type = 'Notice';
self::write_log($type,$errstr,$err['0']['file'],$err['0']['line'],$errfile);
break;
case E_RECOVERABLE_ERROR:
$type = 'Catchable';
self::write_log($type,$errstr,$err['0']['file'],$err['0']['line'],$errfile);
break;
default:
$type = 'Unknown Error';
self::write_log($type,$errstr,$err['0']['file'],$err['0']['line'],$errfile);
break;
}
}
with note that i use trigger_error function to tell about errors …
so help me plz to extract true details about every error occure in any part of my script fomt the method getTrace().
thx