Is there a difference between get and input in laravel's request?
phpcn_u1582
phpcn_u1582 2017-05-16 16:53:54
0
1
313
public function foo(Request $request)
{
    $foo = $request->get('a');
    
    $foo = $request->input('a');
}

Is there any difference between using get and input here?

phpcn_u1582
phpcn_u1582

reply all(1)
某草草

It’s different.

After looking at input to get the array, I simply performed the fetch operation.
get has a more complete fetch mechanism, and there are also many exception-throwing operations.

For specific information, LZ can check the source code:
The input method is at: /vendor/laravel/framework/src/Illuminate/Http/Request.php/vendor/laravel/framework/src/Illuminate/Http/Request.php
get方法在:/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.phpThe get method is at: /vendor /symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php

PS, I currently have 4.2

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!