Different Types of Errors in php?
Posted: Fri Jan 23, 2009 10:33 am
Hi,
I used the Function:
set_error_handler(array($this->Log,'BuildPHPErrorLog'));
to make my LogController Class (function "BuildPHPErrorLog") handle the Errors.
BuildPHPErrorLog creates a Log Object, fills it with ErrorMessage, Code, Line, File and Context and then saves it to the Mysql DB.
$Parameter = array(
"LogType" => 0, # this means php error
"ExceptionMessage" => $ErrorString,
"ExceptionCode" => $ErrorNo,
"ExceptionFile" => $ErrorFile,
"ExceptionLine" => $ErrorLine,
);
$Log = new Log($Parameter);
$Log->SaveToDb($this->DB);
After that I had several new Errors in my DB, such as a warning from my date() function, because I missed to set up a Timezone or complains why I hardly use "if(isset($var)) { use $var; }", most of the time I use $var without checking for existance.
These are some of the "new" errors I detected, but there are some other Errors my Function doesnt handle, such as:
$div = 10 / 0;
This should throw a "Division by 0"-Error or something like that.
@strpos(); should throw a "I need at least 1 Parameter" Error ...
but there´s nothing to find in the DB...
So I think "Div by 0" and some other Errors are of some kind of other Type, which issnt affected by
"set_error_handler(array($this->Log,'BuildPHPErrorLog'));"
So I need help ^^
I used the Function:
set_error_handler(array($this->Log,'BuildPHPErrorLog'));
to make my LogController Class (function "BuildPHPErrorLog") handle the Errors.
BuildPHPErrorLog creates a Log Object, fills it with ErrorMessage, Code, Line, File and Context and then saves it to the Mysql DB.
$Parameter = array(
"LogType" => 0, # this means php error
"ExceptionMessage" => $ErrorString,
"ExceptionCode" => $ErrorNo,
"ExceptionFile" => $ErrorFile,
"ExceptionLine" => $ErrorLine,
);
$Log = new Log($Parameter);
$Log->SaveToDb($this->DB);
After that I had several new Errors in my DB, such as a warning from my date() function, because I missed to set up a Timezone or complains why I hardly use "if(isset($var)) { use $var; }", most of the time I use $var without checking for existance.
These are some of the "new" errors I detected, but there are some other Errors my Function doesnt handle, such as:
$div = 10 / 0;
This should throw a "Division by 0"-Error or something like that.
@strpos(); should throw a "I need at least 1 Parameter" Error ...
but there´s nothing to find in the DB...
So I think "Div by 0" and some other Errors are of some kind of other Type, which issnt affected by
"set_error_handler(array($this->Log,'BuildPHPErrorLog'));"
So I need help ^^