0

我需要帮助。我目前正在尝试使用 PHP 路由 AltoRouter,但它对我不起作用。这是我的代码:

require_once __DIR__ . '/vendor/autoload.php';

$router = new AltoRouter();

$router->map('GET', '/', function(){

    echo 'It is working';
});

$match = $router->match();

// Here comes the new part, taken straight from the docs:

// call closure or throw 404 status
if( $match && is_callable( $match['target'] ) ) {
   
   call_user_func_array( $match['target'], $match['params'] );

} else {

   // no route was matched
   header( $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');

}

我的浏览器输出: 我的浏览器输出

我找到的现有答案列表仍然不适用于我的代码。我需要帮助。这完全弄乱了我的头。非常感谢!

我发现的当前答案并没有为我解决:

PHP AltoRouter - 无法
通过 Php AltoRouter 获取 GET 请求路由

4

0 回答 0