2017-07-30 36 views

回答

2

认为该文档参照传递nullset_exception_handler函数,而不是作为一个参数到用户定义的回调。回调应该永远不会收到空参数。

传递nullset_exception_handler复位到PHP内置的异常处理。这似乎相当于拨打restore_exception_handler

让我们来测试一下:

<?php 
$eh = function($err) { echo 'Here'; }; 
set_exception_handler($eh); 
throw new \Exception('Problem'); 

输出:

Here

而且现在null

<?php 
$eh = function($err) { echo 'Here'; }; 
set_exception_handler($eh); 
set_exception_handler(null); 
throw new \Exception('Problem'); 

输出:

Fatal error: Uncaught exception 'Exception' with message 'Problem' in ...

Stack trace: ...

+0

OOOOH,实际上有一定道理。谢谢 – Svish

相关问题