Is there any way to find out if this warning was supressed or not using the set_error_handler() function? The code is 2 for @somethingwrong() and somethingwrong(). But I don't want to log all warnings. For example some functions like gzuncompress() must be handled this way because I have no way to test for valid input data.
$handler = new errorHandler();
error_reporting(0);
set_error_handler(array($handler, 'handle'));
set_exception_handler(array($handler, 'exception'));
register_shutdown_function(array($handler, 'shutdown'));
class errorHandler
{
public function handle($code, $text, $file, $line)
{
if (($code & (E_STRICT | E_NOTICE)) == 0)
$this->log(...);
}
public function exception($exception)
{
...
}
public function shutdown()
{
$e = error_get_last();
if ($e !== NULL)
$this->log($error);
}
}
// the errors
include('notexisting.file'); // should be logged
@gzuncompress('somenonsens'); // should not be logged