在Laravel控制器中检索GET和POST数据 [英] Retrieving GET and POST data inside Laravel controller

查看:77
本文介绍了在Laravel控制器中检索GET和POST数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在网上搜索如何在控制器内获取POST数据,到目前为止,我已经找到了两种解决方案: Input :: get() $ _ POST .

I've been searching the web for how to get POST data inside the controller, so far I have found two solutions: Input::get() and $_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()?

What is this "named" source they refer to? What is it I should use instead of Input::get() ?

推荐答案

文档显示您可以检索任何内容的输入值使用 Input :: get()的HTTP动词.

The documentation shows you can retrieve an input value for any HTTP verb by using Input::get().

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

这篇关于在Laravel控制器中检索GET和POST数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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