thinkphp5如何跳轉到其他頁面並傳值
阿新 • • 發佈:2019-01-09
在tp5框架中,有一個重定位功能時,像這樣就是
public function insert(){ //獲取表單提交過來的資料 $data=input('param.'); $type=$data['type']; //將資料插入到資料庫中 $result=Db::name('records')->insert($data); //跳轉到首頁顯示 return $this->redirect('index',array('type'=>$type)); } ——>這一句就是重定位到index頁面 :return $this->redirect('index');
這樣可以實現跳轉到其他頁面,
並且想在重定位時傳值的話,程式碼如下:
$type=$_GET['type'];
return $this->redirect('index',array('type'=>$type));
同時在Index頁面,可以使用如下程式碼獲取到傳過來的$type的值。:
$data=input('param.');
$type=$data['type'];
或者
$type=input('param.type')