PHP 标头重定向到具有时间间隔的多个 URL [英] PHP Header redirect to Multiple URLs with a time gap

查看:32
本文介绍了PHP 标头重定向到具有时间间隔的多个 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 header() 重定向到多个 URL 之间的时间间隔吗?假设我有 url1 和 url2.现在,我想要的是标题首先重定向到 url1.然后说,5 秒后,它会将我重定向到 url2.有没有办法我可以做到这一点?我尝试了以下简单代码

Can i use header() to redirect to multiple URLs with a time gap in between? Suppose i have url1 and url2. Now, what i want is that header first redirects to url1. Then say,after 5 seconds, it redirects me to url2. Is there a way i can do that? I tried the following simple code

<?php
header("Location: url1");
header("Location: url2");
?>

但这会立即将我带到 url2.我想要两者之间的时间间隔.怎么可能呢?提前致谢.

But this takes me immediately to url2. I want a time gap in between. How can that be done? Thanks in advance.

推荐答案

正如 subirkumarsao、Martin 和 Edmunds 所指出的,iframe 是要走的路.这是最终代码:

As pointed out by subirkumarsao, Martin and Edmunds, iframes is the way to go. Here is the final code:

<html>
<iframe src="url1" width="500" height="500"> </iframe>
</html>

<?php
include('exp2.php');
?>

现在 exp2.php 有一个提交按钮(它出现在框架的底部),它把我带到 next.php.next.php 有代码:

Now exp2.php has a submit button(This appears at the bottom of frame) which takes me to next.php. And next.php has the code:

<?php
header("Location:url2");
exit();
?>

这篇关于PHP 标头重定向到具有时间间隔的多个 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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