Laravel更改输入值 [英] Laravel change input value

查看:111
本文介绍了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']);

这是文档的链接

这篇关于Laravel更改输入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆