Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webbasics
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
webbasics
Commits
7ac11f2e
Commit
7ac11f2e
authored
Jul 14, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated docs for Router.
parent
af804e03
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
1 deletion
+28
-1
router.php
router.php
+28
-1
No files found.
router.php
View file @
7ac11f2e
...
@@ -13,14 +13,41 @@ namespace BasicWeb;
...
@@ -13,14 +13,41 @@ namespace BasicWeb;
require_once
'base.php'
;
require_once
'base.php'
;
/**
/**
* A Router is used to call a handler function with corresponding to an URL.
*
*
* Simple example: a website with the pages 'home' and 'contact'.
* <code>
* function home() {
* return 'This is the home page.';
* }
*
* function contact() {
* return 'This is the contact page.';
* }
*
* $router = new Router(array(
* '/home' => 'home',
* '/contact' => 'contact'
* ));
* $response = $router->call_handler('/home'); // 'This is the home page.'
* $response = $router->call_handler('/contact'); // 'This is the contact page.'
* </code>
*
*
* You can use regular expression patterns to specify an URL. Any matches are
* passed to the handler funtion as parameters:
* <code>
* <code>
* function page($pagename) {
* return "This is the $pagename page.";
* }
*
*
* $router = new Router(array(
* '/(home|contact)' => 'page'
* ));
* $response = $router->call_handler('/home'); // 'This is the home page.'
* $response = $router->call_handler('/contact'); // 'This is the contact page.'
* </code>
* </code>
*
*
* @package BasicWeb
* @package BasicWeb
* @todo Example
*/
*/
class
Router
extends
Base
{
class
Router
extends
Base
{
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment