From a class I wrote...
-- snip --
// hack to work around the inability to use a method as
// a callback for the set_error_handler function
// NOTE: if you forget the '', then all of the settings
// to class properties will be lost
$GLOBALS['_ERROR_HANDLER_OBJECT'] = $this;
$GLOBALS['_ERROR_HANDLER_METHOD'] = 'error_handler';
// inside function to handle the redirection to a class method
function eh($type, $message, $file=null, $line=null, $vars=null)
{
return $GLOBALS['_ERROR_HANDLER_OBJECT']-
$GLOBALS['_ERROR_HANDLER_METHOD']($type,
$message, $file, $line, $vars);
}
// start handling errors
set_error_handler('eh');
-- snip --
This uses a trick wrapping the actual callback in an inside function.
HTH.
Pete.
Dan Rossi wrote:
hi guys i am having an issue getting a set error handler to get a function
within a class, i am also having problems trying to trigger the error, i
dont want fatals or the error handler wont catch it anyway , but user or
message picks up annoying messages like undefined index on variable , how
can i achieve this properly
this seems to work within the constructor
set_error_handler(array($this, 'myErrorHandler'));
but this way only works in 4.3 ? i need it backwards compatible
trigger_error (Cannot divide by zero, E_USER_WARNING);
this is the trigger
function myErrorHandler ($errno, $errstr, $errfile, $errline, $context) {
plus this , is errrno supposed to return the error type or a code
sorry to e vague its late
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php