Friday, 3 April 2009

PHP Flush

I was writing a script that needed to show download progress so flushing content to the users browser was required...oddly enough flush() alone didn't work. I found this is a solution


ob_end_flush();
echo "Downloading...";
/* download code goes here */
sleep(3) //simulate a download
flush();
echo "Download complete";


Why does this work? Dunno but for some reason ob_end_flush(); before a flush made it work.

0 comments: