Number of PHP alerts / notifications

Is there a way to count the number of errors / notifications / warnings that the script encountered during execution?

I want to do something like this:

Warnings: 125
Notices: 234
..etc

      

thank

+2


source to share


2 answers


$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 needed :)

+7


source


You can use set_error_handler()

to define a custom error handler that increments the global counter and also logs / displays the error.



0


source







All Articles