美文网首页
php自定义的异常处理函数set_exception_handl

php自定义的异常处理函数set_exception_handl

作者: 会飞_的鱼 | 来源:发表于2018-03-30 15:19 被阅读10次

    函数作用

    设置默认的异常处理程序,用于没有用 try/catch 块来捕获的异常,在调用异常处理函数之后程序会终止。

    实例

    <?php
    function exception_handler($exception) {
      echo "出现错误: " , $exception->getMessage(), "\n";
    }
    
    set_exception_handler('exception_handler');
    
    throw new Exception('Uncaught Exception');
    echo "Not Executed\n";
    ?>
    

    相关文章

      网友评论

          本文标题:php自定义的异常处理函数set_exception_handl

          本文链接:https://www.haomeiwen.com/subject/nzdicftx.html