Output buffer

software development

#1

hi

I was wondering why print(fread()) or echo fread()
doesn’t send out the line that it read immediatly. It seems to wait
until the entire file is in the memory then it sends it out. I created
a script to get files from a hidden directory and send it out of the
main directory, but it takes about 80sec for a 35.5mb file to start
sending the buffer to the user. I am using:

while (!feof($fp)) {
set_time_limit(0);
print(fread($fp, 1024));
ob_flush(); // I tried it without this aswell
flush(); // I tried it without this aswell
}

I found this aswell and it explains in better words whats happening, but does anyone have a solution for this? :

Several servers, especially on Win32, will still buffer the output
from your script until it terminates before transmitting the results
to the browser. (http://us2.php.net/manual/en/function.flush.php)