当前位置:首页 > 建站笔记 > 正文

php怎么实现3秒跳转页面

php实现3秒跳转页面的方法:1、使用“header('Refresh:3,Url=页面地址')”语句;2、使用“echo "<meta http-equiv='refresh' content='3; url=页面地址'>";”语句。

本教程操作环境:windows7系统、PHP7.1版、DELL G3电脑

php实现3秒跳转页面的方法

1、使用Header函数

<?php
header("Content-type:text/html;charset=utf-8");
header('Refresh:3,Url=http://www.bailiuli.com/');   //3s后跳转
echo '3s 后跳转';
//由于只是普通页面展示,提示的样式容易定制
die;
?>

2、使用echo输出meta

<?php
header("Content-type:text/html;charset=utf-8");
echo '3s 后跳转';
echo "<meta http-equiv='refresh' content='3; url=http://www.bailiuli.com'>";
die;
?>

注意,content中的数字3的意思是经过多久开始跳转,这里设置的是3就是说要经过3秒钟该页面才会跳转到目标页面,建议大家在设置跳转时间的时候不要超过10秒。

发表评论