Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
38 lines (36 loc) · 844 Bytes

File metadata and controls

38 lines (36 loc) · 844 Bytes
Copy raw file
Download raw file
Outline
Edit and raw actions

Basic Router

About Basic Router

Basic Router is a very basic and small Router class builded in PHP.

Usage

1. First require the class

require 'router.class.php';

2. Add a page

$router->newPage('Hello World', 'hello-world', function(){
	echo 'Hello World!';
});

3. Than get the content

$page = $router->getContent($_GET['page'], '%title% « MyWebPage');

4. Than add the stuff the page

<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title><?php echo $page['title'] ?></title>
</head>
<body>
	<ul>
		<?php foreach($router->getMenu('index.php', '?page=%slug%') as $url => $name): ?>
			<li><a href="<?php echo $url ?>"><?php echo $name ?></a></li>
		<?php endforeach ?>
	</ul>
	<p><?php $page['content']() ?></p>
</body>
</html>
Morty Proxy This is a proxified and sanitized view of the page, visit original site.