Skip to content

Instantly share code, notes, and snippets.

@ringmaster
Created November 4, 2012 18:00
Show Gist options
  • Save ringmaster/4012795 to your computer and use it in GitHub Desktop.
Save ringmaster/4012795 to your computer and use it in GitHub Desktop.
Even vs Odd Routes with different names?
/**
* 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