thinkphp5如何跳转到其他页面并传值

在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')

你可能感兴趣的:(thinkphp,PHP,thinkphp,php,传值,重定位)