fork download
  1. <?php
  2.  
  3. class Route {
  4.  
  5. private $class;
  6. private $action;
  7.  
  8. /* маршрутизатор */
  9. public function getRoute($RouteGet) {
  10. $exp = explode('/', $RouteGet);
  11. $this->Controller = $exp[0];
  12. $this->Action = $exp[1];
  13. }
  14.  
  15. /* роутинг */
  16. public function runRoute() {
  17. $class = $this->Controller;
  18. $action = $this->Action;
  19. $file = CONTROLLER.$class.'.php';
  20.  
  21. if(!file_exists($file)) {
  22. $class = 'frontpage';
  23. $action = 'main';
  24. } require_once $file;
  25.  
  26. $controller = new $class;
  27. if(is_callable(array($controller, $action)) == false) {
  28. $action = 'main';
  29. } $controller->$action();
  30. }
  31.  
  32. /* старт роутера */
  33. public function startRoute() {
  34. $file = CONTROLLER.$this->Controller.'.php';
  35. if(empty(ROUTE)){
  36. $this->Controller = 'frontpage';
  37. $this->Action = 'main';
  38. $this->runRoute();
  39. exit(); }
  40. if(!file_exists($file)){
  41. $this->Controller = 'frontpage';
  42. $this->Action = 'main';
  43. $this->runRoute();
  44. exit(); }
  45. $this->runRoute();
  46. }
  47. }
Runtime error #stdin #stdout #stderr 0.01s 20552KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Parse error:  syntax error, unexpected ')', expecting :: (T_PAAMAYIM_NEKUDOTAYIM) in /home/D5Cenx/prog.php on line 35