利用php的set_error_handler()函数,在zf的引导类文件或初始化类文件中添加如下代码:

1 public function __construct($application) {
2     parent::__construct($application);3
3     MyApp_Error_Handler::set();
4 }

 

定义MyApp_Error_Handle类

 1 class MyApp_Error_Handler {
 2     public static function handle($errno, $errstr, $errfile, $errline)
 3     {
 4         if (!error_reporting()) return;
 5         throw new Exception($errstr . " in $errfile:$errline". $errno);
 6     }
 7 
 8     public static function set()
 9     {
10         set_error_handler(array(__CLASS__, 'handle'));
11     }
12 }

 

相关文章:

  • 2022-01-29
  • 2021-11-20
  • 2021-11-26
  • 2021-11-08
  • 2021-12-28
  • 2022-12-23
  • 2021-12-06
  • 2021-12-16
猜你喜欢
  • 2022-01-07
  • 2021-06-16
  • 2022-01-10
  • 2021-12-14
  • 2021-10-21
相关资源
相似解决方案