1-1Controller之Request
laravel5.5版本
//路由:
Route::any('request1',['uses'=>'StudentController@request1']);
//控制器中的方法:
public function request1(Request $request) { //Controller Request 取得是url中的内容:http://laraveltest.com/request1?name=sean&sex=boy //1.取值: //echo $request::input("name");//取url中的name值: //echo $request::input('sex',"未知");//如果没有取默认值 //2.判断请求中是否有该参数: /* if ($request::has('sex')) { echo $request::input('sex'); } else { echo "无该参数"; }*/ //3.取出请求中所有的值: /*$res=$request::all(); dd($res);*/ //4.请求的类型: //获取请求的类型: //echo $request::method(); //判断请求的类型: /*if ($request::isMethod('GET')){ echo "YES"; }else{ echo "No"; }*/ //判断请求的类型是否是ajax请求 //var_dump($request::ajax()); //5. //http://laraveltest.com/student/request1?name=sean&sex=boy //判断请求前缀是否是student开头的。 /*$res=$request::is('student/*'); var_dump($res);*/ //6.获取当前的url echo $request::url(); }