Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ob_end_flush() suddenly exits the PHP script

Tags:

php

Working on a shared web server used by other developers and designers. Processing XML documents. The following code had always worked for me until the other day:

while (ob_get_level() > 0) { ob_end_flush(); }

Since then, whenever ob_end_flush() is reached, the script appears to die as if ob_end_flush() has an exit(). No errors are output even with error reporting/display_errors on. When commenting out the above line, the script will run fully, displaying script output only once the full script has run. @ob_end_flush() made no difference. ob_get_level() is 1. var_dumping ob_end_flush() would also exit. Using CodeIgniter, but trying this code outside of the framework produced same result.

Is there a reason why ob_end_flush() would suddenly start causing the script to die each time? Are there any PHP settings I should be checking?

like image 794
user1182894 Avatar asked Sep 04 '26 11:09

user1182894


1 Answers

Found the problem at last - When my code seemed to start working outside of CodeIgniter, I checked CodeIgniter's index.php bootstrap file and came across this code that someone had added:

if (substr_count( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')){ 
      ob_start("ob_gzhandler");
} 
else {
     ob_start(); 
}

This was the cause.

like image 145
user1182894 Avatar answered Sep 06 '26 00:09

user1182894



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!