php - 在 Laravel Controller 中检索 GET 和 POST 数据

标签 php laravel http-post http-get

我一直在网上搜索如何在 Controller 中获取 POST 数据,到目前为止我找到了两个解决方案:Input::get()$_POST.

Input::get() 的注释如下:

/**
 * Gets a "parameter" value.
 *
 * This method is mainly useful for libraries that want to provide some flexibility.
 *
 * Order of precedence: GET, PATH, POST
 *
 * Avoid using this method in controllers:
 *
 *  * slow
 *  * prefer to get from a "named" source
 *
 * It is better to explicitly get request parameters from the appropriate
 * public property instead (query, attributes, request).
 *
 * @param string  $key     the key
 * @param mixed   $default the default value
 * @param Boolean $deep    is parameter deep in multidimensional array
 *
 * @return mixed
 */

他们指的这个“命名”来源是什么?我应该使用什么来代替 Input::get()

最佳答案

documentation表明您可以使用 Input::get() 检索任何 HTTP 动词的输入值。

$name = Input::get('name');

关于php - 在 Laravel Controller 中检索 GET 和 POST 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18761555/

相关文章:

php json_encode 带有西里尔字符

php - 如何在 laravel 上将字符串从 jquery 翻译为blade

php - 使用 Laravel 5 将文件上传到数据库中

php - 在 Laravel 中使用 Eloquent 访问特定列

ajax - ajax请求是否需要重定向后获取?

php - 使用 php 将图像上传到磁盘并在 mysql 数据库中保存图像名称

php - Linux Mint 18 PHP5.6 不工作

php - 无法在 magento 2 rest 中使用 paypal 下订单

android - 从 Android 将 JSONArray 发布到 WCF 服务

php - php.ini 中的 max_input_vars 实际影响什么,什么是安全的高值?