$router->addRoute('GET', '/users', function () { // return a list of users });
$router->addRoute('GET', '/users/{id:\d+}', function ($id) { // return user with ID $id });
$route = $router->match($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']); if ($route) { $route->run(); } else { header('HTTP/1.1 404 Not Found'); }This code matches the current request to a route in the router's route list, and runs the corresponding action. If there is no match, it sends a 404 Not Found status. Overall, the PHP Router instance is a useful package library for PHP developers who need a flexible and powerful routing solution.