PHP 计时器等待 30 秒然后运行命令

编程入门 行业动态 更新时间:2024-10-28 16:16:57
本文介绍了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屋!

更多推荐

[db:关键词]

本文发布于:2023-03-28 18:11:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/738929.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:计时器   命令   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!