获取请求类的几种方式:

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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
  • 2021-05-24
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案