} // 3. throw without catch class DivideByZeroException extends Exception { } //Throw new DivideByZeroException("DivideByZeroException1"); // 4. throw with exception handler // can NOT hook a exception_handler class ExceptionHandler { static $callback = array(); static function _exceptionHandler($e) { var_dump('ExceptionHandler'); call_user_func(self::$callback, $e); } } function exception_handler($exception) { var_dump('exception_handler', $exception->getTraceAsString(), 'exception_handler_end'); } set_exception_handler('ExceptionHandler::_exceptionHandler'); aop_add_before('set_exception_handler()', function ($jp) { $args = $jp->getArguments(); ExceptionHandler::$callback = $args[0]; $jp->setArguments(array('ExceptionHandler::_exceptionHandler')); }); set_exception_handler('exception_handler'); //Throw new DivideByZeroException("DivideByZeroException3"); $redis->connect('192.168.1.1', 6379, 1); $redis->ping();