   [web] PHP flush
  Hey guysI need help using the PHP flush function.I'm making a one time call to a php script and I want it to keep outputing stuff back to the client before it ends (inside a loop) I tried using the flush function but it doesn't work..can anyone help? C.   
  The default behavior in PHP is that whenever you output something, it is directly sent to the user browser (which is often a good idea because it uses less server-side memory). If you wish to disable this default behavior, you have to use output buffering. You do this by calling the function ob_start(): any text you output after calling that function is kept on the server in a special buffer, and remains there until you flush or clear the buffer. The buffer is automatically flushed when the script ends.   ;  As ToohrVyk mentioned, PHP by default echos the output immediately without any buffering so no flush should be required. If you (or some script you are using) has turned output buffering on, you might want to use ob_flush() or ob_end_flush() to turn it off completely. See PHP Output Control. Try putting the following lines before your loop starts:ob_implicit_flush(true);ob_end_flush();If this makes any difference, then the problem was with PHP's output buffering.Also remember that sometimes web servers and web browsers also perform their own buffering, this is something you cannot easily control via PHP. If you are using Apache you might want to read this comment that shows how to disable all kinds of buffering and gzip compression at the start of the script. And to quote more from that page: Quote:Several servers, especially on Win32, will still buffer the output from your script until it terminates before transmitting the results to the browser.Server modules for Apache like mod_gzip may do buffering of their own that will cause flush() to not result in data being sent immediately to the client.Even the browser may buffer its input before displaying it. Netscape, for example, buffers text until it receives an end-of-line or the beginning of a tag, and it won't render tables until the </table> tag of the outermost table is seen.Some versions of Microsoft Internet Explorer will only start to display the page after they have received 256 bytes of output, so you may need to send extra whitespace before flushing to get those browsers to display the page. ;  I've been reading a lot about performance lately, and output buffering is one of the best solutions, because it allocates big blocks of memory at a time.  After you call flush, you need to call ob_start() again to restart buffering.   