我想用set_error_handler来统一收集错误,在打印自定义错误提示前,我用了ob_end_clean();但是报错了
PS:我开启了gzip
测试代码:
error_reporting(E_ALL);set_error_handler(array('test', 'handle_error'));if(function_exists('ob_gzhandler')) { ob_start('ob_gzhandler');} else { ob_start();}class test { public static function handle_error($errno, $errstr, $errfile, $errline) { if($errno) { debug::system_error($errstr); } }}class debug { public static function system_error($message) { ob_end_clean(); echo $message; exit; }}echo '错误前信息<br/>';trigger_error('错误内容');
顺便贴一下错误:
chrome浏览器下
错误 330 (net::ERR_CONTENT_DECODING_FAILED):未知错误
error_reporting(E_ALL);set_error_handler(array('test', 'handle_error'));if(function_exists('ob_gzhandler')) { ob_start('my_ob_gzhandler');} else { ob_start();}class test { public static function handle_error($errno, $errstr, $errfile, $errline) { if($errno) { debug::system_error($errstr); } }}class debug { public static function system_error($message) { ob_clean(); echo $message; exit; }}echo '错误前信息<br/>';trigger_error('ddddddddddddddddddddddddd误内容');function my_ob_gzhandler($buffer,$mod){ header("Content-Encoding: gzip"); return gzencode($buffer, 9, FORCE_GZIP);} PHP code?1234567891011121314151617181920212223242526272829303132333435363738394041error_reporting(E_ALL); set_error_handler(array('test', 'handle_error')); if(function_exists('ob_gzhandl……
人才啊,,,感谢
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号