Laravel 更改输入值
在laravel中,我们可以通过Input::get('inputname')
获取输入值.我尝试通过执行此操作来更改值 Input::get('inputname') = "new value";
.但是,我收到错误消息说Can't use function return value in write context
.
In laravel, we can get the input value via Input::get('inputname')
. I try to change the value by doing this Input::get('inputname') = "new value";
. But then, I get the error message saying Can't use function return value in write context
.
我们是否可以更改输入值,以便稍后调用 Input::get('inputname')
时将获得新的修改值?
Is it possible for us change the input value so that when later calling on Input::get('inputname')
will get the new amended value?
谢谢.
推荐答案
您可以使用 Input::merge()
替换单个项目.
You can use Input::merge()
to replace single items.
Input::merge(['inputname' => 'new value']);
或者使用Input::replace()
替换整个输入数组.
Or use Input::replace()
to replace the entire input array.
Input::replace(['inputname' => 'new value']);
这是一个文档链接
相关文章