只是想知道有什么区别:
$username = $request->input('username');
和
$username = Input::get('username');
最佳答案
没有区别,门面Input从request调用输入法。但是 Input::get
已被弃用,更喜欢 $request->input
而不是 Input::get
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Http\Request
*/
class Input extends Facade
{
/**
* Get an item from the input data.
*
* This method is used for all request verbs (GET, POST, PUT, and DELETE)
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public static function get($key = null, $default = null)
{
return static::$app['request']->input($key, $default);
}
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'request';
}
}
关于php - Laravel 5 $request->input 与 Input::get,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35316302/