Ob_end_clean error. please advise! -Php Tutorial

Source: Internet
Author: User
Ob_end_clean error. please advise! I want to use set_error_handler to collect errors in a unified manner. before printing the custom error prompt, I used ob_end_clean (); but reported an error.

PS: I enabled gzip.

Test code:

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 'error message
'; Trigger_error ('error content ');


If the code above is tested, an error is reported... It doesn't matter if ob_end_clean () is commented out...

I am not familiar with ob_start. please kindly advise!


Reply to discussion (solution)

By the way, the following error occurs:
In chrome
Error 330 (net: ERR_CONTENT_DECODING_FAILED): Unknown error

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 'error message
'; Trigger_error ('ddddddddddddddddddddddddddd error content'); function my_ob_gzhandler ($ buffer, $ mod) {header ("Content-Encoding: gzip"); return gzencode ($ buffer, 9, FORCE_GZIP );}

PHP code? Struct (E_ALL); set_error_handler (array ('test', 'handle _ error'); if (function_exists ('OB _ gzhandl ......

Talent, thank you

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.