include 'Router.php'; $router = new Router; $router->get('/', function () { return 'Hello World!'; }); $router->run();
include 'Router.php'; $router = new Router; $router->get('/users/(:num)', function ($userId) { return 'User ID: ' . $userId; }); $router->run();In this example, we create a new route that is dynamic and based on an ID number. This route is defined using a regular expression which matches any numeric value at the end of the URI. When a user visits a URL like "/users/123", the function will return "User ID: 123". The package library used for PHP Router URIs depends on the specific implementation. There are many PHP routing libraries available, such as FastRoute, Aura.Router, and Symfony Routing.