简体   繁体   English

Laravel 中 request->merge() 和 request->add() 有什么区别

[英]What is the difference between request->merge() and request->add() in Laravel

What is the difference between request->merge() and request->add() in Laravel Laravel 中 request->merge() 和 request->add() 有什么区别

I know both of them they add new key-value to input request but whats difference ?我知道他们都向输入请求添加了新的键值,但有什么区别?

the method add() is not defined on the class Request of Illuminate\Http, it is defined on the class ParameterBag of Symfony\HttpFoundation which is the result of calling the protected method getInputSource() . add()方法没有定义在 Illuminate\Http 的Request 类上,它定义在 Symfony\HttpFoundation 的ParameterBag上,这是调用受保护方法getInputSource()的结果。

The method merge() does that for you方法merge()为您执行此操作

public function merge(array $input)
{
    $this->getInputSource()->add($input);

    return $this;
}

Nothing that you can't discover with test and source code reading没有什么是您通过测试和源代码阅读无法发现的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM