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();
    }
}

猜你喜欢

转载自www.cnblogs.com/lichihua/p/10428859.html