无法在Laravel中获取获取变量 [英] Can't retrieve get variables in Laravel

查看:145
本文介绍了无法在Laravel中获取获取变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

routes.php中包含以下内容:

I have the following in my routes.php:

Route::controller('hello', 'HelloController');

我的HelloController.php中包含以下内容:

And I have the following in my HelloController.php:

use Input;
use Illuminate\Http\Request;

public function getIndex(Request $request) 
{
    echo "hi";
    $param = $request->input('param');
    echo $param;
}

当我转到我的URL /hello?param=testparam时,$param值没有任何输出.有什么想法吗?

When I go to my URL /hello?param=testparam nothing is outputed for the $param value. Any ideas?

更新 当我在URL中输入此内容时:index.php/hello?param=testparam.它工作正常.这使我相信它与漂亮的URL有关.

Update When I enter this in my URL: index.php/hello?param=testparam. It works fine. This leads me to believe it has something to do with pretty URLs.

推荐答案

正如我在上面的评论中所述,在测试之后,您错过了包括对函数getIndex的调用.

As said in my comment above, and after tests, you missed including the call to the function getIndex.

您必须这样做:

Route::controller('hello', 'HelloController@getIndex');

这篇关于无法在Laravel中获取获取变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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