在PHP中使用Timer重定向?

编程入门 行业动态 更新时间:2024-10-10 12:26:21
本文介绍了在PHP中使用Timer重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

说10秒钟后如何使用PHP进行重定向...

How can I make a redirect with PHP after say 10 seconds...

我已经阅读了大量有关它的内容,似乎使用javascript会更好.但是PHP可以节省很多代码.

I have read alot about it, seems like it would be better with javascript. But PHP would save me alot of coding.

那么如何在PHP中使用计时器进行重定向?

So how can I make a redirect with timer in PHP ?

谢谢

推荐答案

您可以使您的PHP脚本休眠10秒钟,

You can cause your PHP script to sleep for 10 seconds,

sleep(10);

,但这对于最终用户将显示为无响应服务器.最好的选择是使用元刷新,

but this will appear to the end-user as a non-responsive server. The best option is to use either a meta refresh,

<meta http-equiv="refresh" content="10;url=google">

或javascript.

or javascript.

setTimeout(function(){ window.location = "google"; }, 10000);

在丹尼尔的评论中找到:

Found in the comments from Daniel:

header('Refresh: 10; URL=yoursite/page.php');

对于这种情况将是理想的,因为它不需要Javascript或HTML.

would be ideal for this situation, as it requires no Javascript or HTML.

更多推荐

在PHP中使用Timer重定向?

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

发布评论

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

>www.elefans.com

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