Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.