note 36973 added to function.flush
| From: | m at rco dot php dot net | Date: | Wed, 29 Oct 2003 12:22:55 +0000 |
| Subject: | note 36973 added to function.flush | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59467@lists.php.net to get a copy of this message | ||
in order to display in HTML pages something like a "progress bar" or if you want to force
the web server to flush output to the browser, or the browser to flush as well, you can print a long
enough "dummy" string to make the output buffer grow, as you probably know, like:
print "[";
for($i = 0; $i < 100; $i++){
$spaces.=" ";
} // for
//and then
for($i = 0; $i < 10; $i++){
for($ii = 0; $ii < 200000; $ii++){
//do something slow here
} // for
print "$spaces|";
flush();
} // for
print "]";
/*
but this somethin may be not really what you expect in
a progress bar, as it prints spaces (although rendered as single by the browser) between the bar
units..
you can solve this using
$spaces.="<!-- bufferme -->";
/*
print "[";
for($i = 0; $i < 100; $i++){
$spaces.="<!-- bufferme -->";
} // for
//and then
for($i = 0; $i < 10; $i++){
for($ii = 0; $ii < 200000; $ii++){
//do something slow here
} // for
print "$spaces|";
flush();
} // for
print "]";
//which looks nice as a progress bar..
----
Manual Page -- http://www.php.net/manual/en/function.flush.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36973
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36973&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36973&report=yes
Search -- http://master.php.net/manage/user-notes.php