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

ked*_*ter 2 php redirect timeout

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

Imr*_*ran 6

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

使用睡眠和标题

<?php
sleep(2);
header('Location: http://www.example.com/');
?>
Run Code Online (Sandbox Code Playgroud)

使用<meta>标签

<meta http-equiv="refresh" content="2;url=http://www.example.com/">
Run Code Online (Sandbox Code Playgroud)

  • ```header("refresh:5; http://www.example.com/");``` (9认同)
  • ......并使用JS (2认同)