Multiple Routing (All in one)

Parameters

// This example will match any page name$route->get('/?', function($page) {echo"you are in $page";});// This example will match anything after post/ - limited to 1 argument$route->get('/post/?', function($id) {// Will match anything like post/hello or post/5 ...// But not match /post/5/titleecho"post id $id";});// more than parameters$route->get('/post/?/?', function($id, $title) {echo"post id $id and title $title";});

For “unlimited” optional parameters, you can do this:

// This example will match anything after blog/ - unlimited arguments$route->get('/blog/*', function() {// [$this] instanceof ArrayObject so you can get all args by getArrayCopy() pre($this->getArrayCopy()); pre($this[1]); pre($this[2]);});

Named Parameters

You can specify named parameters in your routes which will be passed along to your callback function.