Buffer flush doesn't work quite as expected

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I've got a PHP script (running on MacOS X, PHP 4.1.12) which uploads  
bookings from one database to another, and I'd like to have the screen show  
progress as it happens (each time I process a booking, I write a line  
summarising it to the browser with 'print')

From RTFMing and Googling, it seems that I should be able to do this by  
turning output buffering on and using ob_flush() et al. However, this only  
sort-of works, in that instead of getting output line by line, I get a  
multi-line chunk on the browser from time to time.

Am I stuck with having this chunk-by-chunk visualisation, or can anyone  
please suggest a way that I can make it force each line to the browser as I  
write it?

Thanks in anticipation,

David C

Re: Buffer flush doesn't work quite as expected

Here is an example which works for me, but I personaly recommend not to
use buffering at all
function sample($buffer) {
    global $i;
    if(!isset($i)) $i = 1;
    $bufer = "$i<br />";
    return ($bufer);

// don't forget to start buffering


// and don't forget to end it

Re: Buffer flush doesn't work quite as expected

Quoted text here. Click to load it

the result you see may depend on your browser, web server etc...  
I did something similar in perl and got character by character output in
mozilla but not in IE.


Site Timeline