PHP flush() apparently works on my Linux machine but not on my windows machine?

Viewed 400

I'm trying to become familiar with PHP's flush() function for a project I'm doing, I wrote a few scripts myself, and uploaded them to some webspace I own; but it seemed none of them worked. I picked up the one below from a comment on PHP.net and tried it:

<?php
header( 'Content-type: text/html; charset=utf-8' );

echo 'Begin ...<br />';
for( $i = 0 ; $i < 10 ; $i++ )
{
    echo $i . '<br />';
    flush();
    sleep(1);
}
echo 'End ...<br />';

Apparently the script STILL wasn't working.

I then read a comment that said:

If you call ob_flush() and flush() and still dont get the buffer flushed it might be because some antivirus software (Panda in this case) holds the buffer until the page has finished loaded before sending it to the browser.

So I decided to request the webpage on a machine I have using Linux (Ubuntu 12.04) as that doesn't have any anti-virus software installed; and it worked perfectly!

I have no idea if this is to do with anti-virus software? Or some other strange mechanism in Windows that is preventing flush() from achieving it's intended purpose, I'm using the same browser on both machines (Firefox 14.0.1) so I doubt it can be that.

So I guess my real question is: Does anybody know anything about anti-virus software preventing flush() from achieving it's intended purpose (because I can't seem to find anything about it online) ? And if so, is there any way to get around it?

EDIT: Just to clear up, I'm positive this is NOT server side, I have an external web server running Linux, I am not hosting these scripts locally on either the Linux or Windows Machine.

EDIT2: I tried this around a friends house on the Linux Laptop that I managed to get it working on at my house, strangely the flush code also didn't work at their house (instead it just took ages to load and all came out at once) which is strange as it works on this laptop in my house, I'm not sure if routers have anything to do with the flush() function working (I really can't find anything about this on the web) because that is the only thing I can think of that could interfere with it.

Otherwise I've made no progress trying to get around this on my own, this is definitely not to do with the server end, which is strange as most information I seem to find is talking about the server being the issue when the flush() function isn't working :/

Coincidentally I also tried this on a PC running Norton (instead of AVG) at my house, it worked but not quite 100%.

1 Answers
Related