查询和输入的区别

par*_*ini 3 php laravel

之间有什么区别

$request->query()

$request->input() 在 Laravel 中?

它们都返回相同的结果。

mat*_*iit 5

官方文档中直接提到了:

虽然输入方法从整个请求负载(包括查询字符串)中检索值,但查询方法只会从查询字符串中检索值:

https://laravel.com/docs/5.5/requests


小智 5

这两种方法的一个重要部分,

$request->input() ::可以使用任何 HTTP 动词(例如 GET,POST,..)

$request->query() ::只能检索从查询字符串传递的数据( GET 方法)

如果您仅使用查询字符串来传递数据,则两种方法都会得到相同的结果,但如果您使用任何其他 HTTP 方法(可能带有查询字符串值),您会发现差异。


Ken*_*day 4

在本机 PHP 编码中。

$request->input() is the equivalent of $_REQUEST  //this is either querystring or form-data submission.

$request->query() is just a straight forward $_GET   //this is querystring
Run Code Online (Sandbox Code Playgroud)