php header方法跳转页面问题
生活随笔
收集整理的這篇文章主要介紹了
php header方法跳转页面问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
php header方法跳轉頁面:1、立即跳轉,代碼為【header('Location:other.php')】;2、提示跳轉,代碼為【header('Refresh:3,Url=other.php');echo '3s 后跳轉'】。
php header方法跳轉頁面:
header()為php函數,向瀏覽器發送指定命令
html:
<meta http-equiv="Refresh" content="3;url=other.php"/>
立即跳轉:
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"<meta http-equiv=\\"refresh\\" content=".$sec.";URL=".$url.">";
echo $info;
}
die;
}
相關學習推薦:PHP編程從入門到精通
總結
以上是生活随笔為你收集整理的php header方法跳转页面问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 银行信用卡业务宣传文案28句
- 下一篇: 帝加偏旁在组词