3

since two days i'm trying to stop the buffer on my server, i disabled the output_buffering in php.ini i checked it was disabled with phpinfo().

Under xampp(Localhost) it works like a charm, same testing code(below), the code runs without waiting for everything to be finished, no buffer, a dream =)

On my server the output_buffering show me No value in phpinfo() so i think it's disabled, but still it's not workingn i need to wait until the loop finish his work, anyway to make this work like on my xampp config ? thanks !

testing code here :

for($i=1; $i<=5000; $i++){ echo $i."<br>"; flush(); usleep(1000); } 

ps : i tested with php 5.6 & php7 on Debian and Ubuntu, my xampp is naturally running on windows(10)

2
  • if you want this kind of browser interaction you should use client side code Commented Nov 22, 2016 at 20:06
  • Possible duplicate of How to flush output after each `echo` call?. Check out the second answer which appears to solve it by sending out a content-type header. Commented Nov 22, 2016 at 20:24

2 Answers 2

0

You need to use ob_flush() and flush()

What's the difference you may ask? That's a good question.

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

1 Comment

thanks, i just tried but still won't work :( it wait to finish before allow me to see the output
0

Modern browsers don't display anything until the body of the response contains a certain amount of data (about 1024 bytes). The following may look a bit hacky - but like this it works as expected:

<?php echo '<!-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -->'; flush(); for($i=1; $i<=5000; $i++) { echo $i."<br>"; flush(); usleep(1000); } ?> 

1 Comment

thanks, it still wont work :( i can't figure why, working like a charm on xampp

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.