php不能header跳转页面,PHP问题:php header方法跳转页面问题

php header方法跳转页面:1、立即跳转,代码为【header('Location:other.php')】;2、提示跳转,代码为【header('Refresh:3,Url=other.php');echo '3s 后跳转'】。

259079f941f2f9578ac7c9e578054c29.png

php header方法跳转页面:

header()为php函数,向浏览器发送指定命令

html:

立即跳转:

header('Location:other.php');

//file_put_contents('bee.txt','execute');

die;

执行header时候,并不是立即结束,而是会把页面执行完毕;在header前面不能有任何输出,若有开启输出缓冲则不提示错误,

php.ini->output_buffering = 4096|OFF

提示跳转:

header('Refresh:3,Url=other.php');

echo '3s 后跳转';

//由于只是普通页面展示,提示的样式容易定制

die;

封装的跳转函数:

/*

*跳转

*@param $url 目标地址

*@param $info 提示信息

*@param $sec 等待时间

*return void

*/

function jump($url,$info=null,$sec=3)

{

if(is_null($info)){

header("Location:$url");

}else{

// header("Refersh:$sec;URL=$url");

echo"";

echo $info;

}

die;

}

相关学习推荐:PHP编程从入门到精通

以上就是php header方法跳转页面问题的详细内容!

相关内容

————————————————

欢迎通过PayPal赞助本站持续维运: PayPal赞助页面

————————————————

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值