gpt4 book ai didi

php - Laravel 5 $request->input 与 Input::get

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:07:59 25 4
gpt4 key购买 nike

只是想知道有什么区别:

$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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com