PHP 标头重定向到具有时间间隔的多个 URL

2022-01-11 00:00:00 header php

我可以使用 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();
?>

相关文章