0

In wamp server, I cannot flush the output buffer unless I use these functions:

ob_end_flush(); ob_flush(); flush(); ob_start(); 

Why do I need to use all of these functions? Why does simple ob_flush() is not working? my code :

<?php ob_start(); header( 'Content-type: text/html; charset=utf-8' ); echo 'Begin ...<br />'; for( $i = 0 ; $i < 6 ; $i++ ) { echo $i . '<br />'; sleep(1); ob_end_flush(); ob_flush(); flush(); ob_start(); } echo 'End ...<br />'; ?> 

1 Answer 1

2

Because you have by default parameter output_buffering = on

Go to C:\wamp\bin\php\php5.4.3\php.ini

And find line

output_buffering = On

and change it to

;output_buffering = On

Sign up to request clarification or add additional context in comments.

8 Comments

you are king! but why do I need to use "ob_flush" and "flush" together? sorry for my english, i am from Israel.
You can find the answer here. It's pretty hard to answer for me, but you could just explain what is your purpose in using output buffering :>
Why do I need to delete the sentence about "output_buffering" in PHP.INI? Is there an explanation?
@Lior because it is written in the file (at least in my php.ini): ; Note: This directive is hardcoded to Off for the CLI SAPI ; Default Value: Off
Or you could just set the value to Off: output_buffering = Off
|