php 抛出异常 自定义,PHP自定义错误页面
现在,我们要考虑2个案例:
>该站点处于调试模式
>该站点未处于调试模式
现在PHP错误处理,对于案例#1:
我们希望看到错
每个人都说在活动站点中“显示启用错误”是不好的(由于某些安全问题). 现在,我们要考虑2个案例: >该站点处于调试模式 >该站点未处于调试模式 现在PHP错误处理,对于案例#1: 我们希望看到错误.怎么样? ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); 没有比这更简单了.我们还可以为除Parse和Fatal之外的所有错误自定义错误处理程序. 相反,如果案例是#2: 我们希望能够停用消息: ini_set('error_reporting', 0); ini_set('display_errors', 0); 没关系.但是如何向用户展示一个友好的信息,例如“Hei man,有些东西真的很好.我不保证你我们正在努力修复它,因为我们非常懒惰.” 您应该再次启用错误并使用函数set_error_handler()并希望不会发生解析或致命错误.但我的第一个问题是: Question 1: Is that possible to avoid error reporting and have a custom offline page that is loaded when something goes wrong? I mean, is it possible to have ini_set('error_reporting', 0); and ini_set('display_errors', 0); and still be able to tell PHP to load a custom Error page? 现在另一个: Question 2: I developed a class that with the power of set_error_handler() logs errors occurred into the database. In this way I can keep track of hack attempts and other cool stuff. (And yes, i’m always sure the DB is accessible since my application shuts down if we cannot connect to the DB). Is this worth something? (编辑:成都站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |