我想将 url 数据放入我的输入值中。
Example:
- the url is http://example.com/user?username=example
- and my html input code is as below
<input value="{{ request()->input('username') or old('username') }}">
- but the result always return "1" and not "example"
似乎“或” Blade 助手充当条件运算符。
如何从 url 获取用户名值并将其作为旧值('username')获取?
最佳答案
尝试
<input value="{{ request()->input('username', old('username')) }}">
如果用户名存在或默认为旧值,它将检索用户名作为输入。您还可以为旧助手提供默认值。
关于php - Laravel request->input ('' ) or old ('' ) 总是在 blade 中返回 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38935860/