如何在PHP中的一段时间后将访问者重定向到另一个页面?

时间:2011-05-04 03:18:34

标签: php redirect timeout

PHP在页面上放置超时并将其重定向到另一个页面时有哪些隐藏的技巧?

1 个答案:

答案 0 :(得分:6)

您可以在服务器端使用sleep,然后使用header重定向到另一个页面。或者,您可以发送带有<meta>标记的HTML页面,该标记指定重定向位置和延迟时间。

使用sleep和标题

<?php
sleep(2);
header('Location: http://www.example.com/');
?>

使用<meta>代码

<meta http-equiv="refresh" content="2;url=http://www.example.com/">
相关问题