[SOLVED] Flush(), ob_flush() not working in PHP (Disabling gzip through htaccess)

Flushing the output buffer doesn’t works in PHP sometimes no matter what you do. I had this code which would never work on my server but would perfectly fine on localhost. This was the code.

ini_set('zlib.output_compression', 0);
for($i=0;$i<10;$i++) {
      echo $i;
      echo str_repeat(" ", 500);

I knew this had to do with Server configuration as the php code was fine. Then after searching a lot I stumbled across a page where it said that my host had recently enabled gzip for all pages, I instantly knew this was the problem.

So I made a .htaccess file in the folder where this script was and entered the following:

SetEnv no-gzip dont-vary

Saved the file. And it started buffering.


Leave a Reply

Your email address will not be published. Required fields are marked *