简体   繁体   中英

Count Number of PHP Warnings/Notices

Is there a way I can count the number of errors/notices/warnings that a script has come across whilst executing?

I wish to do something like this:

Warnings: 125
Notices: 234
..etc

Thanks

$warn = $notice = 0;  
function f() { 
  global $warn, $notice; 
  $argv = func_get_args(); 
  switch($argv[0]) { 
    case E_WARNING: $warn++; break; 
    case E_NOTICE: $notice++; break; 
  }
}
set_error_handler('f', E_ALL);

Expand as necessary :)

您可以使用set_error_handler()定义一个自定义错误处理程序,该处理程序将增加全局计数器以及记录/显示错误。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM