如何创造动态增长的价值?
我想创建并显示一个每秒增加固定量的值。
我的 PHP 文件中有以下变量:
$AccountValue=220000; $IncreasePerSecond=15;
因此,例如,当页面加载时,一秒后该值将是 220000,另一秒后该值将是 220015 220030 ....等等,
提前致谢
I want to create and display a value which is increasing by a fixed amount per second.
I have the following variables in my PHP file:
$AccountValue=220000;
$IncreasePerSecond=15;
So for example when the page loads the value would be 220000 after one second the value would be 220015 after another second 220030 ....etc
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为最好用 javascript 编写,即客户端(正如 Wernight 已经在他的 答案。
在服务器端,您可以记录该点秒数开始增加。
然后,当再次请求该页面时,您可以在服务器端计算起始点和当前时间之间的秒数。
I think it's best to write this in javascript, i.e. client-side( as Wernight already shows in his answer.
On the server-side you can record the point at which the seconds start to increase.
Then when the page gets requested again you can calculate on the server-side the amount of seconds that are between the starting point and the current time.
这不是完整的答案,但它应该为您提供基础:
请参阅 http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/
It's not the full answer but it should give you the basis:
See http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/