Flushing output
There is a special function in PHP called flush(), which is not really related to output buffering because it works with standard output, however it is so very similar to what we’ve just been looking at that it makes sense to cover it here.
Flush() sends all output out immediately, without waiting for the end of the script, and you can call it as often as you want. Calling flush() has the effect of making the browser update with new content. Take a look at this example script:
Author’s Note: Internet Explorer has an “optimisation” that makes it only render a page after it has received the first 256 bytes whether or not you use flush() – you might find these example scripts do not work as described in IE. That is not to say the concept is wrong – merely that there is not enough room here to demonstrate a longer example! To make the scripts work, make them output at least 256 characters before the first call flush() – in your own scripts, this will not be a problem. Continue reading “php Flushing output”