use \Klein\Klein; $router = new Klein(); $router->respond('/user/[i:id]', function($request, $response, $service){ $id = $request->param('id'); // do something with $id }); $router->dispatch();
use \Klein\Klein; $router = new Klein(); $router->respond('/search', function($request, $response, $service){ $term = $request->param('q', 'default'); // do something with $term }); $router->dispatch();In this example, we define a route for a search page. We use the `$request->param()` method to retrieve the value of a query string parameter called "q". If the parameter is not present in the URL, we default to "default". Overall, the Director urlParam package is a useful PHP library for handling URL parameters in a web application. It makes parsing and manipulating query strings easy and convenient.