大飞_dafei

导航

laravel HTTP 请求, 接受参数处理

01) 判断请求参数是否存在

判断参数在请求中是否存在
$request->has('name')
$request->has(['name', 'email'])

// 判断参数存在且参数值不为空
$request->filled('name')

基础组件 —— HTTP 请求

HTTP Requests

{
    "foo":"bar",
    "hello":"world",
    "da":"",
    "hebei":{
        "shijiazhunag":"石家庄",
        "baoding":"保定"
    }
}




// print_r($request->path());
// print_r($request->method());
// print_r($request->json()->all());
// print_r($request->json("foo"));
// print_r($request->input());
// print_r($request->has('eeee'));
// print_r($request->json("hebei.shijiazhunag"));
// print_r($request->input("hebei.shijiazhunag"));
// print_r($request->only(['foo','hello',"fei"]));
// print_r($request->only(['foo','hello',"shijiazhunag"]));
// print_r($request->except(['foo']));
var_dump($request->has(['foo','hello']));
// var_dump($request->has(['foo','aaaa']));
// print_r($request->get("foo"));
// print_r($request->post("foo"));
var_dump($request->filled('da'));

 

posted on 2020-10-14 09:35  大飞_dafei  阅读(540)  评论(0编辑  收藏  举报