PHP动态计数器?

PHP动态计数器?,php,dynamic,counter,Php,Dynamic,Counter,我在网上找到了这个脚本,我需要修改它以适应我的需要,我也尝试了一些东西,但我已经不知所措了 我找到的脚本位于此处: 我需要一个类似的脚本,基本上将以32000开始(假设8月22日午夜),然后每10分钟增加5 有人能帮我举个例子吗?或者给我举一个其他地方已有的例子 非常感谢!我已从下面包含的链接粘贴了代码: <?php $now = time(); $start = mktime(0, 0, 0, 1, 24, 2007); $carbonsaving =((($now - $start)

我在网上找到了这个脚本,我需要修改它以适应我的需要,我也尝试了一些东西,但我已经不知所措了

我找到的脚本位于此处:

我需要一个类似的脚本,基本上将以32000开始(假设8月22日午夜),然后每10分钟增加5

有人能帮我举个例子吗?或者给我举一个其他地方已有的例子

非常感谢!我已从下面包含的链接粘贴了代码:

<?php

$now = time();
$start = mktime(0, 0, 0, 1, 24, 2007);
$carbonsaving =((($now - $start) * 0.0058774) + 130000);
$format = round($carbonsaving, 2);
// in this example
// $now = a unix timestamp of this very second
// $start is the date that you want the counter to start from sent over //as a unix     timestamp
// $carbonsaving is the calculation that you want to perform to get //your base figure
// i.e. total saving = ((date now - start date)* growth rate) + base rate
// this gives us the starting saving all that needs to be done is increment it with     javascript
?>

<script type="text/javascript">
// we need to import our server side variable into javascript to let it increment live

var car = <?php print($format); ?>;
var rou

function incs()
{
car = car + 0.01;
rou = Math.round(car*100)/100
document.getElementById("carb").innerHTML=rou;
}
// what function incs does is take car and adds 0.01 to it
//rou rounds the figure to 2 dp
//the document.getElementById("carb") can refer to a <p> tag //<span> or whatever and just     says with .innerHTML=rou; that the //value between the results of rou
//hope this helps
//Nicholas King
//ecotricity
</script>
</head>
<!-- body onload setInterval tells the page to load our javascript function and repeat it by     every x microseconds, so this repeats every 2 seconds //-->
<body onload="setInterval('incs()', 2000)">
<div id="carb">Calculating...</div>

//我们需要将服务器端变量导入到javascript中,以使其生效
var-car=;
瓦鲁
函数incs()
{
汽车=汽车+0.01;
rou=数学圆(车*100)/100
document.getElementById(“carb”).innerHTML=rou;
}
//incs的功能是取车并将其添加0.01
//rou将数字四舍五入为2 dp
//document.getElementById(“carb”)可以引用一个标记//或任何东西,只需使用.innerHTML=rou;rou结果之间的//值
//希望这有帮助
//尼古拉斯·金
//生态性
精明的。。。

以下是计算8月22日到现在的“点数”的PHP:

$start = mktime(0, 0, 0, 8, 22, 2011); // Aug 22, 2011
$diff = time() - $start; // seconds between start and now
$extra = 5 * floor($diff / 600);
$result = 32000 + $extra;

基本上是这样的:

$now = time();
$start = mktime(0, 0, 0, 1, 24, 2007);
$init =((($now - $start)) + 130000);
?>

<script type="text/javascript">

var init = <?php print($init); ?>;
var val

function incs()
{
    //Increase by random number (4-6)
    init = init + Math.floor( (Math.random()*4)+3);
    document.getElementById("counter").innerHTML=init;

    //Create a random timer to make it not so obvious.

    var random_timer = Math.floor( (Math.random()*500)+2000);
    setTimeout('incs()',random_timer );
}

</script>
</head>
<body onload="">
    <div id="counter">Calculating...</div>
</body>
$now=time();
$start=mktime(0,0,0,1,242007);
$init=(($now-$start))+130000;
?>
var init=;
瓦尔
函数incs()
{
//按随机数增加(4-6)
init=init+Math.floor((Math.random()*4)+3);
document.getElementById(“计数器”).innerHTML=init;
//创建一个随机计时器,使其不那么明显。
var random_timer=Math.floor((Math.random()*500)+2000);
setTimeout('incs()',随机定时器);
}
精明的。。。
一开始我很难理解这些问题,所以我希望这就是你想要的。 基本上,使用php创建一个starttime,然后使用javascript和随机数来增加这个数字,只要页面处于打开状态。
如果需要,请将Math.floor()替换为静态数字。

您需要它的具体用途是什么?如果我们了解一些背景知识,我们可能会更好地帮助您。我正在尝试在一个网站上放置一个计数器,它从一个基数开始,然后一直上升。例子:这么多人都在Facebook上——345001619,每x分钟就会增加x个数字Hanks Neokio,你的帖子帮我意识到了一些事情。。实际上,我并不需要一个“实时计数器”,只是一个php数学问题,可以计算起始值(32000)+((time()-$start)/x)或类似的东西?更具体地说,我需要从32000开始,每10分钟增加5。等式的起始日期方面开始起作用,因此数字持续攀升,并且不再从32000开始。上面应该正好做到这一点