mirror of
https://github.com/Aviortheking/Blog_IMIE.git
synced 2025-04-23 19:32:15 +00:00
32 lines
566 B
PHP
32 lines
566 B
PHP
<?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");};
|
|
}
|
|
}
|