0

Possible Duplicate:
How to make PHP generate Chunked response

How can I execute something, display its contents, and continue executing it and showing its contents? I don't want to wait until the script is done to echo its content.

An example of this is on http://www.masswhois.com/. The script doesn't wait for all of the whois data to be returned before it starts showing results!

Community
  • 1
  • 1
Eric R.
  • 933
  • 1
  • 9
  • 19
  • 1
    Dupe: http://stackoverflow.com/questions/2481858/how-to-make-php-generate-chunked-response – Matt Mar 08 '11 at 01:54
  • Don't agree that this is an exact dupe. This is not the same as chunked output. – Hamish Mar 08 '11 at 02:12
  • Closed as dupe, except that the answer to the dupe is not accepted and is not actually complete. Fail. – Hamish Mar 13 '11 at 20:23

3 Answers3

0

http://php.net/manual/en/function.flush.php

Patrick Fisher
  • 7,926
  • 5
  • 35
  • 28
0

I'd recommend the following:

// .. inside of loop...
if(ob_get_length()) {
   @ob_flush();
   @flush();
   @ob_end_flush();
}
@ob_start();

This really flushes the content to the server, but the error suppression is also useful to prevent certain configurations throwing (harmless) errors when there is nothing to flush.

Note that this doesn't necessarily prevent other server output modules from doing their own buffering, so output flushing will not be 100% fool-proof on all systems.

Hamish
  • 22,860
  • 8
  • 53
  • 67
0

You are probably using output buffering. If you turn it off completely or use the ob_flush() you'll get what you want.

zombor
  • 3,247
  • 17
  • 30