dongzhunqiu4841 2012-12-19 08:45
浏览 12
已采纳

PHP忽略自定义错误处理程序[重复]

Possible Duplicate:
How do I catch a PHP Fatal Error

I want to create a custom error handler but PHP ignores it still uses the built in error handler. The example below gives a built in fatal error because test() is not defined:

 function critical_error($error_number,$error_string,$error_file,$error_line,$error_context) {
     echo "<strong>error:</strong> echo ".$error_string;
     exit();
 }

 set_error_handler("critical_error",8191);
 test();
 exit;

Any advice?

  • 写回答

1条回答 默认 最新

  • dougaxing8673 2012-12-19 08:47
    关注

    You are probably defining the error level wrong. Try using:

    set_error_handler("critical_error", E_ALL);
    

    Also notice that:

    The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called.

    But without your complete script (including test()) it's hard to tell. I've tested it on my local server and everything works fine.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程