dqxsuig64994 2017-09-25 21:48 采纳率: 0%
浏览 27
已采纳

为什么它说错误层次结构不是来自php中的异常?

I am new to php world and learning from php.net and this paragraph wasted all my day. Can anyone tell what does this paragraph tells on that reference link (http://php.net/manual/en/language.errors.php7.php)?

As the Error hierarchy does not inherit from Exception, code that uses catch (Exception $e) { ... } blocks to handle uncaught exceptions in PHP 5 will find that these Errors are not caught by these blocks. Either a catch (Error $e) { ... } block or a set_exception_handler() handler is required.

  • 写回答

1条回答 默认 最新

  • duanci1858 2017-09-25 21:56
    关注

    It says that the error reporting mechanism has changed in PHP.

    In PHP5 you used to catch exceptions and errors with the following code

    catch (Exception $e) { ... } 
    

    but now in PHP7 you need to use the following code in order to get all errors.

    catch (Error $e) { ... }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制