【发布时间】:2015-11-02 14:22:56
【问题描述】:
我的 routes.php 中有以下内容:
Route::controller('hello', 'HelloController');
我的 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 值输出任何内容。有什么想法吗?
更新
当我在我的 URL 中输入这个:index.php/hello?param=testparam。它工作正常。这让我相信它与漂亮的 URL 有关。
【问题讨论】:
-
你有什么错误吗?你试过 $param = $request->param;
-
@zlen 我正在调用 lluminate\Http\Request 并且仍然为空。
-
@KhanShahrukh 没有错误,我也试过了。
-
好的,如我所见,您没有调用该函数。这样做:Route::controller('hello', 'HelloController@getIndex');
-
你使用的是什么版本的 Laravel?