Jump to content

ob_flush and flush how to use


siddscool19

Recommended Posts

I want to know how to use ob_flush() and flush()..

I am testing this code:

<HTML>
<BODY>
This page is loading.<br />
<?php ob_flush(); flush(); sleep(10); ?>
Almost there...<br />
<?php ob_flush(); flush(); sleep(10); ?>
Done.<br />
</BODY>
</HTML>

But it is not giving me the desired output in firefox :(

 

Am I wrong in using it or it doesn't work with firefox ?

Link to comment
https://forums.phpfreaks.com/topic/154735-ob_flush-and-flush-how-to-use/
Share on other sites

Your script actually works like intended when I run it in Firefox 3.0.8 on PHP 5.2.6. But you're supposed to turn on output buffering with ob_start(). Maybe that'll do it:

 

<?php ob_start(); ?>
<HTML>
<BODY>
This page is loading.<br />
<?php ob_flush(); flush(); sleep(10); ?>
Almost there...<br />
<?php ob_flush(); flush(); sleep(10); ?>
Done.<br />
</BODY>
</HTML>

 

Server settings can also play a part here. And remember that browsers also handle output buffering differently.

It does not work because php, your web server, and your browser combination are doing buffering and/or compression and/or and minimum length block content rendering.

 

You need to refresh the browser or use AJAX to get piecemeal content to be sent to and displayed in a browser that will work for all php/web server/browser combinations and configurations - http://www.phpfreaks.com/forums/index.php/topic,248507.msg1163558.html#msg1163558

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.