只是想知道这两者的区别是什么:
$username = $request->input('username');和
$username = Input::get('username');发布于 2016-02-10 21:27:06
没有区别,外观输入从请求中调用输入方法。但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';
}
}发布于 2016-02-10 21:26:29
两者都是相同的,但这一种幼虫内置的功能,以使幼虫的正确使用。
您可以使用这两种方法,但以下内容仅在输入中完成。就看一眼。
Input::has('name')Input::all()Input::only('username', 'password')Input::except('credit_card')Input::get('products.0.name')还有这件事
Input::get('username');因此,这使得as的事情变得很容易。
另一件事,如果我们使用这个,我们必须做更多的代码。
$request->input('username')希望你能理解。谢谢。
https://stackoverflow.com/questions/35316302
复制相似问题