public static function Run() { self::$url = isset($_GET['url']) ? trim(stripslashes($_GET['url'])) : ''; if (self::absolute_address() === false) { $rout = Rout::init(); self::$controller = $rout['controller']; self::$method = $rout['method']; self::$params = $rout['params']; } $controller = new self::$controller(); if (method_exists($controller, self::$method)) { self::checker($controller); if (!empty(self::$params)) { call_user_func_array(array($controller, self::$method), self::$params); } else { $controller->{self::$method}(); } } }
private static function explode_rout($key) { $route_val_parts = explode('/', $key); $count = count($route_val_parts); self::$controller = $route_val_parts[0]; if (isset($route_val_parts[1])) { self::$method = $route_val_parts[1]; if (isset($route_val_parts[1])) { for ($i = 2; $i < $count; $i++) { array_push(self::$params, $route_val_parts[$i]); } } } }
<?php include_once 'config.php'; session_start(); setlocale(LC_ALL, 'ru_RU.UTF-8', 'Russian_Russia.65001'); header('Content-type: text/html; charset=utf-8'); $q = isset($_GET['q']) ? $_GET['q'] : ''; $rout = new Rout($q); $rout->Request();