PHP sleep accuracy
Posted
by
Abs
on Stack Overflow
See other posts from Stack Overflow
or by Abs
Published on 2011-01-08T23:33:05Z
Indexed on
2011/01/08
23:53 UTC
Read the original article
Hit count: 191
Hello all,
I use the following code to see how long a user is on a particular page. I use a hidden image with a src attribute to this script:
$timer_seconds = 1;
while(!connection_aborted()) {
echo "\n";
flush();
sleep(1);
$timer_seconds++;
}
I sometimes find this can be off by 5-10 seconds! I am guessing its the load of the server that effects the timing??
Is there anyway I can make this accurate?
Thanks all for any help.
© Stack Overflow or respective owner