Page 1 of 1
Error Handler
Posted: Thu Feb 23, 2006 7:47 pm
by Sphenn
Hi,
Does anyone know if you can use a class as an error handler?
I've looked through the documentation, and can't find any info, and my own tests have been inconclusive.
Thanks
Posted: Thu Feb 23, 2006 8:03 pm
by Jenk
In which way, what is the structure of the class and/or your systems logic, and how are you invoking the errors?
Code: Select all
<?php
class error
{
function handler($errno, $errstr, $errfile, $errline)
{
echo "$errno, $errstr, $errfile, $errline";
}
}
set_error_handler(array('error', 'handler'));
trigger_error('this is an error', E_USER_WARNING);
?>
As a static call, using trigger_error and set_error_handler. You can also use the object variable instead of a the (string) ClassName to use an object.
Posted: Thu Feb 23, 2006 8:07 pm
by Sphenn
Ahh...thanks so much
I have an error handler defined, than decides wether or not to send e-mails, log, etc. I'll be calling it using trigger_error().
Thanks again