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
Error Handler
Moderator: General Moderators
In which way, what is the structure of the class and/or your systems logic, and how are you invoking the errors?
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.
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);
?>