PHP sleep() excution sequence while echoeing.
- by Babiker
I have the following:
echo time()."<br>";
sleep(1);
echo time()."<br>";
sleep(1);
echo time()."<br>";
I wrote the preceding code with intention to echo time()."<br>" ln 1,echo time()."<br>" ln 4, wait a final second and then echo the final time()."<br>". Altough the time bieng echoed is correct when it comes to the intervals between time(), all echo functions are echoeing after the total of the waiting period/parameters in each sleep function.
This is how the script runs:
Excutes.
Waits 2 secons.
echoes
1275540664
1275540665
1275540666
Notice the correct incrementation in time() being echoed. My question is why is it not behaving like expected to where it echoes, waits a second, echoes again, waits one final second and then echos the last parameter?
I know my question is a little confusing due to my wording, but i will try my hardest to answer any comments regarding this, thanks.