Home > Backend Development > PHP Tutorial > ob_end_clean 出错了,求教!

ob_end_clean 出错了,求教!

WBOY
Release: 2016-06-23 14:05:18
Original
955 people have browsed it

我想用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('错误内容');
Copy after login


上述代码测试,就报错了。。。ob_end_clean()注释掉就没关系。。。

我对ob_start理解不深,求赐教!


回复讨论(解决方案)

顺便贴一下错误:
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);}
Copy after login

PHP code?1234567891011121314151617181920212223242526272829303132333435363738394041error_reporting(E_ALL); set_error_handler(array('test', 'handle_error'));  if(function_exists('ob_gzhandl……

人才啊,,,感谢

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template