\n"; $output .= ""; return $output; } # defaults work the same as always... dispatch('/', 'hello_world'); function hello_world() { return "Hello world!"; } # able to pass options to routes, which are also available in the 'before' filter in the $route argument dispatch('/account', 'user_account', array("authenticate" => TRUE)); function user_account() { return "You are authenticated (or rather, you would be if the 'authenticate_user' was real)"; } # sometimes there param validation rules that are difficult or impossible to implement as a regex # Here is an example of attaching a validation function to a route. # Call this with /validate/1234 to pass, or with any other argument to fail dispatch('/validate/*', 'validate_test', array('validation_function' => 'a_silly_validation_function')); function validate_test(){ return "Yup! You've passed the validation test"; } run(); //------------------------------ // Utilities //------------------------------ function authenticate_user() { //auth the user here... return true; } function a_silly_validation_function($params) { //perhaps this looks something up in the database... if (isset($params[0]) && $params[0] == "1234") return true; return false; }