tp6参数获取的五种方法
1、当前类继承自BaseController
public function request(){ dump($this->request->param()); dump($this->request->get()); dump($this->request->post()); dump($this->request->param('id')); dump($this->request->param('id',0,'intval')); dump($this->request->param('ids')); dump($this->request->param('ids',3,'intval')); }
2、当前类没有继承自BaseController
通过Request依赖注入
use app\Request; public function index(Request $request){ dump($request->param('abc')); }
3、input
public function func2(){ dump(input('abc')); }
4、助手函数
public function func2(){ dump(request()->param('abc')); }
5、静态方式调用
public function func3(){ dump(Request::param('abc')); }