2

我正在尝试使用AltoRouter,但我正在尝试遵循它的文档,而我的问题是它$_GET总是为空的。

我正在使用 Apache,我的 .htaccess 如下所示:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

现在这是我用来$_GET制作路由器的文件:

$router->map('GET', '/', 'PageController@getShowHomePage', 'home');
$match = $router->match();

list($controller, $method) = explode("@", $match['target']);

if(is_callable(array($controller, $method))) {
  $object = new $controller();
  call_user_func_array(array($object, $method), array($match['params']));
} else {
  echo "Cannot find $controller -> $method";
  exit();
}

但我看到它不起作用,因为当我收到 $_GET 时,它总是空的,我用 aprint_r($_GET)来查看 to $_GET,但返回给我的是一个空数组。

我尝试使用以下 URL,但结果是相同的:

http://localhost/mvc/
http://localhost/mvc/page
http://localhost/mvc/controller
http://localhost/mvc/produto/cadastrar
4

1 回答 1

0

那是因为您在这些 url 中没有查询 (GET) 参数。如果您使用说,获取参数将是: http://localhost/mvc?param=1

你可以从$_SERVER

如果您需要调试帮助,请尝试使用类似kint的工具

于 2015-10-12T20:43:28.590 回答