Home  >  Article  >  Backend Development  >  php waits for a few seconds before jumping

php waits for a few seconds before jumping

angryTom
angryTomOriginal
2019-10-29 10:02:535771browse

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(&#39;正在加载,请稍等...<br>五秒后自动跳转。&#39;); ?>

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=&#39;javascript&#39; type=&#39;text/javascript&#39;>"; 
echo "window.location.href=&#39;$url&#39;"; 
echo "</script>"; 
?>
<?php 
$url = "http://www.guanwei.org"; 
echo "<script language=&#39;javascript&#39; type=&#39;text/javascript&#39;>";
echo "setTimeout(\"window.location.href=&#39;$url&#39;\", 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn