我需要帮助。我目前正在尝试使用 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');
}
我找到的现有答案列表仍然不适用于我的代码。我需要帮助。这完全弄乱了我的头。非常感谢!
我发现的当前答案并没有为我解决: