I'm trying to set up error handling in a general application class. Ideally I'm trying to do something like this:
class ApplicationObject {
var $event_Errors = array ();
function ApplicationObject() { //Constructor
set_error_handler('$this->trapError'); // Point error handling to trapError function
}
function trapError($err_no, $err_str, $err_file, $err_line, $err_context) { // Trap and handle application errors
// Code to store error in event_Error and do some stuff
}
}
$app = new ApplicationObject();
trigger_error ("Cannot divide by zero", E_USER_ERROR);
Basically I'd like the constructor event to set the error handling function to trapError, but the problem is set_error_handler() wants a string and I have no clue as to how to get a reference to $this->trapError as a string. If you don't quote $this->trapError in the set_error_handler() call it will call the trapError function, but not set it as the error handler.
Anyone have the slightest clue how to do this?