search

Home  >  Q&A  >  body text

Is there a difference between get and input in laravel's request?

public function foo(Request $request)
{
    $foo = $request->get('a');
    
    $foo = $request->input('a');
}

Is there any difference between using get and input here?

phpcn_u1582phpcn_u15822789 days ago383

reply all(1)I'll reply

  • 某草草

    某草草2017-05-16 16:55:54

    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

    reply
    0
  • Cancelreply