在Laravel 4中检索控制器内的GET和POST数据

Jan*_*Jan 10 php laravel laravel-4

我一直在网上搜索如何在控制器中获取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
 */
Run Code Online (Sandbox Code Playgroud)

他们所指的这个"命名"来源是什么?我应该用什么而不是Input::get()

小智 9

文件显示,你可以通过使用检索任何HTTP动词的输入值 Input::get().

$name = Input::get('name');
Run Code Online (Sandbox Code Playgroud)