在PHP中,我使用set_exception_handler
函数构建了一个错误处理程序。它正在执行我的自定义异常处理程序。我也希望PHP在执行处理程序后也执行默认的异常处理程序。这是我的代码。
function handleException( exception $e){
echo $e->getMessage();
restore_exception_handler();
}
set_exception_handler( 'handleException');
echo $e->getMessage()
已执行,但是即使使用,默认的PHP异常处理程序也不会执行restore_exception_handler
。那么,如何使它起作用?
您应该在还原后触发先前的异常处理程序
function handleException( exception $e){
echo $e->getMessage();
restore_exception_handler();
throw $e; //This triggers the previous exception handler
}
set_exception_handler( 'handleException');
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句