Posted: Fri Dec 14, 2007 8:36 pm Post subject: Echoing code with time intervals
Scenario Imagine you need a script that gets some data, then
wait some seconds, and gets another data from a DB
/ Array (I used a for loop), this is how I managed
to make it, with the help of killfrog
php:
<?
ob_start();
for ($i=1; $i < 5 ; $i++) {
echo date("H:i:s");
echo "I am displaying after 5 seconds <br>";
ob_flush();
flush();
sleep (5);
}
?>
will output :
Quote:
20:32:32 I am displaying after 5 seconds
20:32:37 I am displaying after 5 seconds
20:32:42 I am displaying after 5 seconds
20:32:47 I am displaying after 5 seconds
Hope it helps some of you
BTW : I was also told that ob_flush() can be
screwed if you have mod_deflate module loaded in
Apache.
To check if it is point your browser here :
http://www.gidnetwork.com/tools/gzip-test.php and give the
url of a page of yours on your server.
If Web Compression is No you have no problems, if it
is Yes, it could mean that it will create some
problems for you. Mine is off, so I couldn't test
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum