phplaravellaravel-4

Difference between get() and all() in laravel


What is difference between these two in laravel

$input = Input::get();

And

$input = Input::all();

And which one i should prefer.


Solution

  • Taken from the laravel source:

    public static function all()
    {
       $input = array_merge(static::get(), static::query(), static::file());
       // ....
       return $input;
    }
    

    So all() calls get() and returns it's contents along with query(), and file() the $_FILES superglobal.

    Preference will obviously depend on circumstance. I personally choose to use Input::get($key, $default) as I usually know what I am after.