note 54710 deleted from language.operators.increment by nlopess
| From: | nlopess@php.net | Date: | Sat, 18 Feb 2006 23:04:05 +0000 |
| Subject: | note 54710 deleted from language.operators.increment by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-104004@lists.php.net to get a copy of this message | ||
Note Submitter: Wout
----
Avoid loops : use --$i or ++$i instead of $i-- or $i++
Try these (the only difference is in the javascript part - it doesn't work with the php header
function).
Name your file countdown.php or change file name in javascript part
--------------
Wrong code :
--------------
<?php
$i = $_GET['i'];
if(!isset($i))
{
$i=5;
}
if($i <= 0)
{
echo "GO !!";
die;
}
echo $i;
sleep(1);
?>
<html><head><script language='JavaScript'>
<!--
window.location="countdown.php?i=<?php echo $i--; ?>";
//-->
</script></head></html>
-------------
Right code :
-------------
<?php
$i = $_GET['i'];
if(!isset($i))
{
$i=5;
}
if($i <= 0)
{
echo "GO !!";
die;
}
echo $i;
sleep(1);
?>
<html><head><script language='JavaScript'>
<!--
window.location="countdown.php?i=<?php echo --$i; ?>";
//-->
</script></head></html>