⑴ thinkphp如何根據域名跳轉到其他目錄頁面
ThinkPHP redirect 方法可以實現頁面的重定向(跳轉)功能。
redirect 方法語法如下:
$this->redirect(string url, array params, int delay, string msg)
參數說明:
參數
說明
url
必須,重定向的 URL 表達式。
params
可選,其它URL參數。
delay
可選, 重定向延時,單位為秒。
msg
可選,重定向提示信息。
ThinkPHP redirect 實例
在 Index 模塊 index 方法中,重定向到本模塊的 select 操作:
classIndexActionextendsAction{
publicfunctionindex(){
$this->redirect('select',array('status'=>1),3,'頁面跳轉中~');
}
}
//不延時,直接重定向
$this->redirect('select',array('status'=>1));
//延時跳轉,但不帶參數,輸出默認提示
$this->redirect('select','',3);
//重定向到其他模塊操作
$this->redirect('Public/login');
//重定向到其他分組
$this->redirect('Admin-Public/login');
⑵ php 中如何實現跳轉到一個新的頁面
1、首先用HTTP頭信息重定向到另外一個頁面的方法,如下圖所示。