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

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

问题描述

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

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

但是这会立即将我带到url2。我想要两者之间的时间差距。如何做到这一点?感谢提前。正如subirkumarsao,Martin和Edmunds所指出的那样,iframes是最好的选择。

解决方案


以下是最终的代码:

 < html> 
< iframe src =url1width =500height =500> < / iframe中>
< / html>

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

现在exp2.php有一个提交按钮(它出现在框架的底部) next.php。 next.php的代码如下:

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


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");
?>

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

解决方案

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');
?>

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天全站免登陆