Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Router {
- public function Run () {
- $route = explode('/', $_SERVER['REQUEST_URI']);
- $controller = !empty($route[1]) ? ucfirst($route[1]) . 'Controller' : 'Product';
- $action = !empty($route[2]) ? 'action' . ucfirst($route[2]) : 'index';
- $params = array_slice($route, 3);
- if ( file_exists(ROOT . '/Frontend/Controller/' . $controller . '.php') ) {
- echo $controller . ' ' . $action;
- $object = new $controller;
- method_exists($object,$action) ? $object->$action : require_once '../frontend/view/view.php';
- }
- else {
- require_once '../Frontend/View/404.php';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment