router mis en place !

This commit is contained in:
2019-01-14 15:09:56 +01:00
parent 013e14b1ed
commit 084725f658
9 changed files with 128 additions and 116 deletions

View File

@ -0,0 +1,31 @@
<?php
class Router {
private static $router;
public function __construct() {
Router::$router = $this;
}
public static function getRouter() {
return Router::$router;
}
private $routeList = array();
public function addRoute($route, $page) {
$this->routeList[$route] = $page;
}
public function dump() {
return $this->routeList;
}
public function search($path) {
foreach ($this->routeList as $reg => $page) {
if(preg_match($reg, $path)) {
return $page;
}
}
return function() {return file_get_contents("../html/404.html");};
}
}