Home > Article > Backend Development > php waits for a few seconds before jumping
php waits for a few seconds before jumping
1. PHP script controls the jump method, through Rewrite HTTP header information to jump
a) header refresh method:
<?php header("refresh:5;url=http://www.XXXXX.com"); print('正在加载,请稍等...<br>五秒后自动跳转。'); ?>
b) header location method:
<?php sleep(3); Header(“location:index.php”); ?>
two , Jump by outputting JavaScript
<?php sleep(3); $url = "http://www.guanwei.org"; echo "<script language='javascript' type='text/javascript'>"; echo "window.location.href='$url'"; echo "</script>"; ?>
<?php $url = "http://www.guanwei.org"; echo "<script language='javascript' type='text/javascript'>"; echo "setTimeout(\"window.location.href='$url'\", 3000)"; echo "</script>"; ?>
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of php waits for a few seconds before jumping. For more information, please follow other related articles on the PHP Chinese website!