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

来源:互联网 发布:如何报考网络大学 编辑:程序博客网 时间:2024/05/01 12:33

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

3 0
原创粉丝点击