PHP定时器等待30秒,然后运行一个命令 [英] PHP Timer wait 30 seconds then run a command
本文介绍了PHP定时器等待30秒,然后运行一个命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是在寻找一个简单的定时器,在那里我能得到我的网页在30秒后运行的脚本。
I'm just looking for a simple timer, where I can get my page to run a script after 30 seconds.
我们的想法是,用户有30秒的时间提交答辩,否则页面将运行一个脚本,并带他们到一个对不起,太慢了风格的页面。
The idea is that the user has 30 seconds to submit an answer, otherwise the page will run a script and take them to a 'sorry, too slow' style page.
我无法找到正确的PHP函数,但它基本上我们是这样的:
I cannot find the correct php function for this, but it basically we be like:
<?php
Start timer(30);
when timer runs out:
header("location: tooslow.php");
?>
感谢您的帮助, 布雷特
Thanks for any help, Brett
推荐答案
您可以在Javascript中使用的setTimeout()做到这一点;
You could do this in Javascript using setTimeout();
var t=setTimeout("killPage",30*1000);
function killPage(){
window.location='/fail.php';
}
function questionComplete(){
t.clearTimeout();
}
这篇关于PHP定时器等待30秒,然后运行一个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文