1.内置函数param
//param函数,tp5内置函数,
public function request(){
//获取所有参数,返回数组
dump($this->request->param();
//具体参数,返回字符串
dump($this->request->param('id');
//intval() 函数用于获取变量的整数值。
dump($this->request->param("abc",1,"intval"));
A:http://www.a.com/index/index/hello/id/1.html ,
B:http://www.a.com/index/index/hello?id=1
C:http://www.a.com/index/index/hello?name=12aa
D:http://www.a.com/index/index/hello?name=aa123dd
A类url返回默认值1,C类URL返回12,D类url返回0
}
- 通过父类(BaseController)中的request实例调用param方法
- param(“名字”,默认值,)
2.依赖注入获取request对象
//也可以使用
dump($request->get("abc"));
post...等等
3.使用input辅助函数获取参数input(“abc”)
dump(input("abc"));//abc为key
4.使用框架提供的request调用param方法
dump(request()->param("abc"));
5.门面模式静态调用
dump(Request::param("abc"));