thinkphp5 Request请求类

获取请求类的几种方式:

1、助手函数(严格不算ba )

input('post.name');

2、$request=\think\Request::instance();

3、控制器中必须继承Controller,那么在方法中可用$this->request;

4、依赖注入 、5、直接 new    

namespace app\admin\controller;
use think\Request;
class User{
    //4、依赖注入 
    public function index(Request $request){

     }
   //5、直接new
     public function show(){
        $request=new Request();
    }
}

 

posted @ 2019-02-25 01:18  虚无缥缈的云  阅读(4136)  评论(0编辑  收藏  举报