I've been recoding a fairly large project with main aim of making it completely object oriented.
I have made a custom error handler class with a member function to handle errors and a constructor to set the member function as the error handler. Something like:-
class error
{
function error
{
set_error_handler(array(&$this, 'error_handler')
}
function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
{
// Code to execute on error.
}
}
$error = new error;
trigger_error('My error!');
Using a member function as the error handler works fine in PHP >= 4.3.0 as it should do according to the docs, but older versions of PHP do not allow for array of object and method to be used as set_error_handler() parameter. Is there any way around this without moving my error handler functions outside of any class?