What are some hidden tricks of PHP in putting timeout on the page and redirect it to another page?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can use sleep
on the server-side then redirect to another page with header
. Or you can send an HTML page with <meta>
tag that specifies redirect location and delay time.
Using sleep and header
<?php
sleep(2);
header('Location: http://www.example.com/');
?>
Using <meta>
tag
<meta http-equiv="refresh" content="2;url=http://www.example.com/">