Hello all,
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
Hello all,
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
You could use set_error_handler()
to define a custom error handler which increments a global counter as well as logging/displaying the error.
$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 :)