mirror of
https://github.com/Aviortheking/Blog_IMIE.git
synced 2025-06-22 22:39:19 +00:00
router mis en place !
This commit is contained in:
31
project/assets/php/router.php
Normal file
31
project/assets/php/router.php
Normal 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");};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user