My Aim: I want to have a string (say "DP") to be keep displaying on the screen after every 5 seconds for 10 times. I am using the following code: <?php for($i=1;$i<=10;$i++) { sleep(5); echo 'DP<br>'; } ?> PHP: But, what the above code does is - the script waits for 50 seconds, and "DP" is displayed 10 times on the screen instantly. Although, the script should first wait for 5 seconds and then display "DP"... then again wait for 5 seconds and display "DP"..... and so on.... for 10 times. Does anyone know where the problem is? It will be really appeciated
Try this: <?php for($i=1;$i<=10;$i++) { echo 'DP<br>'; flush(); sleep(5); } ?> PHP: or, if you really want that initial 5 second delay: <?php for($i=1;$i<=10;$i++) { sleep(5); echo 'DP<br>'; flush(); } ?> PHP: