alexandrheathen

Untitled

Feb 12th, 2019
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class Router {
  5. public function Run () {
  6. $route = explode('/', $_SERVER['REQUEST_URI']);
  7. $controller = !empty($route[1]) ? ucfirst($route[1]) . 'Controller' : 'Product';
  8. $action = !empty($route[2]) ? 'action' . ucfirst($route[2]) : 'index';
  9. $params = array_slice($route, 3);
  10. if ( file_exists(ROOT . '/Frontend/Controller/' . $controller . '.php') ) {
  11. echo $controller . ' ' . $action;
  12. $object = new $controller;
  13. method_exists($object,$action) ? $object->$action : require_once '../frontend/view/view.php';
  14. }
  15. else {
  16. require_once '../Frontend/View/404.php';
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment