Created
November 4, 2012 18:00
-
-
Save ringmaster/4012795 to your computer and use it in GitHub Desktop.
Even vs Odd Routes with different names?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Only accept even arguments in the URL | |
*/ | |
$app->route('even', new Regex('#^/number/(?P<number>[0-9]+)/?$#'), function(){ | |
echo "The number was even."; | |
})->validate(function($request) { return $request['number'] % 2 == 0;}); | |
/** | |
* Only accept odd arguments in the URL | |
*/ | |
$app->route('odd', new Regex('#^/number/(?P<number>[0-9]+)/?$#'), function(){ | |
echo "The number was odd."; | |
})->validate(function($request) { return $request['number'] % 2 == 1;}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment