simplePHPRouter
simplePHPRouter copied to clipboard
Further options in url
` // www.webpage.com/component/blog/... Route::add("/component/(.*)", function($urlComponent){ echo $urlComponent; // resolt ist blog });
// www.webpage.com/component/blog/option/list
// this link will call first routh
Route::add("/component/(.*)/option/(.*)", function($urlComponent, $urlOption){
echo $urlComponent . " and " .$urlOption;
// we hawe not this resolt see. we will see from first rout
// how to enable this secon ?
});
`
you should put the second before the first if you want it to work.... or not using (.) as regex but something like ([a-z-0-9]) instead. That will remove the '/' from the regex and keep only letters hyphens and numbers.
So something like this:
Route::add("/component/([a-z-0-9]*)", function($urlComponent){
echo $urlComponent;
});
Route::add("/component/([a-z-0-9]*)/option/([a-z-0-9]*)", function($urlComponent, $urlOption){
echo $urlComponent . " and " .$urlOption;
});