php header方法跳转页面问题
生活随笔
收集整理的這篇文章主要介紹了
php header方法跳转页面问题
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
php header方法跳轉(zhuǎn)頁面:1、立即跳轉(zhuǎn),代碼為【header('Location:other.php')】;2、提示跳轉(zhuǎn),代碼為【header('Refresh:3,Url=other.php');echo '3s 后跳轉(zhuǎn)'】。
php header方法跳轉(zhuǎn)頁面:
header()為php函數(shù),向?yàn)g覽器發(fā)送指定命令
html:
<meta http-equiv="Refresh" content="3;url=other.php"/>
立即跳轉(zhuǎn):
header('Location:other.php');
//file_put_contents('bee.txt','execute');
die;
執(zhí)行header時(shí)候,并不是立即結(jié)束,而是會(huì)把頁面執(zhí)行完畢;在header前面不能有任何輸出,若有開啟輸出緩沖則不提示錯(cuò)誤,
php.ini->output_buffering = 4096|OFF
提示跳轉(zhuǎn):
header('Refresh:3,Url=other.php');
echo '3s 后跳轉(zhuǎn)';
//由于只是普通頁面展示,提示的樣式容易定制
die;
封裝的跳轉(zhuǎn)函數(shù):
/*
*跳轉(zhuǎn)
*@param $url 目標(biāo)地址
*@param $info 提示信息
*@param $sec 等待時(shí)間
*return void
*/
function jump($url,$info=null,$sec=3)
{
if(is_null($info)){
header("Location:$url");
}else{
// header("Refersh:$sec;URL=$url");
echo"<meta http-equiv=\\"refresh\\" content=".$sec.";URL=".$url.">";
echo $info;
}
die;
}
相關(guān)學(xué)習(xí)推薦:PHP編程從入門到精通
總結(jié)
以上是生活随笔為你收集整理的php header方法跳转页面问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 银行信用卡业务宣传文案28句
- 下一篇: 帝加偏旁在组词