[英]$request->only() return empty array in laravel 7.9
I have a mess while laravel 5.4 to 7.9, I have read the follow document: https://laravel.com/docs/7.x/requests , but I am not clear in my case:我在 laravel 5.4 到 7.9 时一团糟,我已阅读以下文档: https://laravel.com/docs/7.x/requests ,但我不清楚我的情况:
In laravel 5.4, it returns an array:在 laravel 5.4 中,它返回一个数组:
It's an emty array in laravel 7.9:它是 laravel 7.9 中的一个空数组:
Thanks!谢谢!
The problem you are describing is expected behaviour and was changed in between versions.您描述的问题是预期的行为,并且在版本之间进行了更改。
The only
method returns all of the key / value pairs that you request, even if the key is not present on the incoming request. only
的方法返回您请求的所有键/值对,即使传入请求中不存在该键。 When the key is not present on the request, the value will be null
.当请求中不存在密钥时,该值将为
null
。
The only
method returns all of the key / value pairs that you request; only
的方法返回您请求的所有键/值对; however, it will not return key / value pairs that are not present on the request.但是,它不会返回请求中不存在的键/值对。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.