加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php自定义异常

发布时间:2020-12-13 16:26:59 所属栏目:PHP教程 来源:网络整理
导读:我想知道如何编写自定义异常处理程序. 所以我可以做类似的事情 抛出新的dbException($sql,$message); 并输出 There was an error in your query Message: {$message here} Query: {$sql here} Line: {line exception was thrown on} File: {file exception w
我想知道如何编写自定义异常处理程序.

所以我可以做类似的事情

抛出新的dbException($sql,$message);

并输出

There was an error in your query
Message: {$message here}
Query: {$sql here}
Line: {line exception was thrown on}
File: {file exception was thrown from}

但我也想抓住例如语法错误和解析错误(如果可能的话)

嗯,你可以 extend the Exception class但是你喜欢.对于自定义例外,您可能需要查看帖子:

> PHP 5 OOP: Delegation and Custom Exceptions

您还应该发现此线程有用:

> Custom Exception Messages: Best practices

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读