PHP 计时器等待 30 秒然后运行命令 [英] PHP Timer wait 30 seconds then run a command

查看:22
本文介绍了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");
?>

感谢您的帮助,布雷特

推荐答案

你可以在 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆