timers counting down on a still page
Moderator: General Moderators
-
chopficaro
- Forum Commoner
- Posts: 68
- Joined: Fri Jan 01, 2010 12:56 am
timers counting down on a still page
my friend is all asp, and he made these timers that count down as soon as the page is loaded. like u load the page and everything on the page is still except for this timer counting down hours minuits and seconds. is there a way to do this in php?
- Grizzzzzzzzzz
- Forum Contributor
- Posts: 125
- Joined: Wed Sep 02, 2009 8:51 am
Re: timers counting down on a still page
As far as i know, no. PHP is all about running serverside on request and then providing output, it doesn't run clientside, so cannot act past the inital request.
You can in javascript though, and very easily too.
You can in javascript though, and very easily too.
Last edited by Grizzzzzzzzzz on Mon Jan 11, 2010 6:34 pm, edited 1 time in total.
- SimpleManWeb
- Forum Commoner
- Posts: 57
- Joined: Wed Dec 30, 2009 4:15 pm
- Location: New Hampshire, USA
-
SidewinderX
- Forum Contributor
- Posts: 407
- Joined: Fri Jul 16, 2004 9:04 pm
- Location: NY
Re: timers counting down on a still page
Technically speaking, you are correct. However, I was surprised when I saw the results of the following code (in firefox).Grizzzzzzzzzz wrote:As far as i know, no. PHP is all about running serverside on request and then providing output, it doesn't run clientside, so cannot act past the inital request.
You can in javascript though, and very easily too.
Code: Select all
<?php
ob_end_flush();
$count = 10;
for($i = 1; $i <= $count; $i++) {
sleep(1);
echo $i;
flush();
}
?>
Re: timers counting down on a still page
Nothing like having your script run for a full ten seconds. 
-
SidewinderX
- Forum Contributor
- Posts: 407
- Joined: Fri Jul 16, 2004 9:04 pm
- Location: NY
Re: timers counting down on a still page
Indeed. Still pretty neat though.
- Grizzzzzzzzzz
- Forum Contributor
- Posts: 125
- Joined: Wed Sep 02, 2009 8:51 am
Re: timers counting down on a still page
If you REALLLLLLLLLLLLLLLLLY wanted to get a php clock/timer, you could always.....
but as with the other work-a-round, it's terrible and you'd be much better off with javascript.
Code: Select all
<?php
echo date("H:i:s");
echo "<meta http-equiv=\"refresh\" content=\"1\"/>";
?>
-
chopficaro
- Forum Commoner
- Posts: 68
- Joined: Fri Jan 01, 2010 12:56 am
Re: timers counting down on a still page
thanks guys ill try out the javascript