Is there any way to pass variable to the set_exception_handler() method in PHP? I need something like this:
class Clazz {
public /* static */ function foo() {
set_exception_handler(array('Clazz', 'callback'), $var); // I need to pass $var
// or this in non-static context
$that = $this;
set_exception_handler(array($that, 'callback'), $var); // I need to pass $var
}
public static function callback($exception, $var) {
// process $exception using $var
}
}
As i already indicated in the comment you have to use lambda-functions anyway: