B0b Posted March 1, 2010 Share Posted March 1, 2010 Hey guys, Apparently flush won't flush on my new server. This will hold the buffer up to the end: for ( $i = 0; $i <= 10; $i++) { echo 'Foo ' . $i . ' Bar' . '<br/>'; flush(); wait( 1 ); } Any clue of what's going on? Thanks so much! Quote Link to comment https://forums.phpfreaks.com/topic/193836-flush-not-flushing/ Share on other sites More sharing options...
genericnumber1 Posted March 1, 2010 Share Posted March 1, 2010 You might check your PHP.ini for the output_buffering setting. Make sure that is disabled. Also make sure you're not using any other output buffers (ob_start(), etc) Edit: Also, did you define wait() elsewhere or did you mean sleep? Quote Link to comment https://forums.phpfreaks.com/topic/193836-flush-not-flushing/#findComment-1020161 Share on other sites More sharing options...
B0b Posted March 1, 2010 Author Share Posted March 1, 2010 Thank you very much for the reply. In phpinfo, output_buffering is set to 4096. Does that mean it output only after 4096 bytes are cached? If so, how should that be changed in a local php.ini file, if it's possible? Edit: I meant sleep Quote Link to comment https://forums.phpfreaks.com/topic/193836-flush-not-flushing/#findComment-1020165 Share on other sites More sharing options...
genericnumber1 Posted March 1, 2010 Share Posted March 1, 2010 You should try setting... output_buffering = Off and using sleep (so you can see the delay). That should hopefully do it. Edit: For setting the directive just for the one file, you would have to do it in .htaccess. The ini_set function can not modify output_buffering. Quote Link to comment https://forums.phpfreaks.com/topic/193836-flush-not-flushing/#findComment-1020168 Share on other sites More sharing options...
B0b Posted March 2, 2010 Author Share Posted March 2, 2010 Hum... yes, I'd like to have it in a .htaccess file, but having in: output_buffering = Off Gives me a 500 Internal Server Error: "Invalid command 'output_buffering'"... hum?.. Quote Link to comment https://forums.phpfreaks.com/topic/193836-flush-not-flushing/#findComment-1020177 Share on other sites More sharing options...
roopurt18 Posted March 2, 2010 Share Posted March 2, 2010 <?php ini_set( 'output_buffering', false ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/193836-flush-not-flushing/#findComment-1020195 Share on other sites More sharing options...
B0b Posted March 2, 2010 Author Share Posted March 2, 2010 Seems like that's too simple to fix the problem :-\ Still no flushing... Quote Link to comment https://forums.phpfreaks.com/topic/193836-flush-not-flushing/#findComment-1020202 Share on other sites More sharing options...
PFMaBiSmAd Posted March 2, 2010 Share Posted March 2, 2010 Have you read the information in the flush() section of the php documentation? You must also disable all of the buffering (including the buffering being done to accomplish compression) that the web server is doing. Short-answer: web servers and browsers were never intended for output from a single http request to be sent this way. Quote Link to comment https://forums.phpfreaks.com/topic/193836-flush-not-flushing/#findComment-1020210 Share on other sites More sharing options...
B0b Posted March 2, 2010 Author Share Posted March 2, 2010 I got it to work with one of the posts in PHP documentation: @apache_setenv('no-gzip', 1); @ini_set('zlib.output_compression', 0); @ini_set('implicit_flush', 1); for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); } ob_implicit_flush(1); All that to be able to flush Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/193836-flush-not-flushing/#findComment-1020219 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.