Do not log supressed PHP Warning -
is there way find out if warning supressed or not using set_error_handler() function? code 2 @somethingwrong() , somethingwrong(). don't want log warnings. example functions gzuncompress() must handled way because have no way test 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); } } // errors include('notexisting.file'); // should logged @gzuncompress('somenonsens'); // should not logged
did try it? think if use @ in @gzuncompress not normal warning , not have errorhandler called.
Comments
Post a Comment