flush() Not displaying output in PHP? -
i have code:
set_time_limit(0); header("cache-control: no-cache, must-revalidate"); header("expires: mon, 26 jul 1997 05:00:00 gmt"); ob_flush(); flush(); $start = time(); $secs = time() - $start; while ($secs <= 300) { echo "this script has been running $secs seconds.\n"; ob_flush(); flush(); sleep(1); }
what i'd when view page, see in real time how long script has been running, this:
- script has been running 1 seconds.
- script has been running 2 seconds.
- ............
- script has been running 300 seconds.
instead blank window continuous 'loading' sign 5 minutes, , after 5 mins i'm bombarded load of these messages should've been getting 1 message @ time.
can explain i'm doing wrong?
ob_flush
not flush
. ob_flush
clears object buffer that's been opened. since don't have object buffer open, nothing flushed.
also, web browsers , web server software notorious holding data until can outputted. make sure gziping turned off , you're using sane browser.
Comments
Post a Comment