Simple router in PHP











up vote
1
down vote

favorite












Before I start writing my first MVC framework, I want to improve my code quality as much as I can, can anyone give me some constructive criticism on how I can improve this?



It is a simple router, built for simple use. It should be pretty simple what's going on, and the usage should be easy to picture. It's nothing major but works well for simple functionality using it.



<?php

class Router {

public $routes = ;
public $routeMethods = ;

public function get($route, $settings) {
$this->add($route, $settings, ['GET']);
}

public function post($route, $settings) {
$this->add($route, $settings, ['POST']);
}

public function add($route, $settings, $methods) {
$this->routes[$route] = $settings;
$this->routeMethods[$route] = $methods;
}

public function dispatch() {
$requestUrl = $_SERVER['QUERY_STRING'];

if (array_key_exists($requestUrl, $this->routes)) {
$route = $this->routes[$requestUrl];
$methods = $this->routeMethods[$requestUrl];
$method = $_SERVER['REQUEST_METHOD'];

if (!in_array($method, $methods)) {
echo 'Method ' . $method . ' not allowed.';
}
else {
$controller = $route['controller'];

if (class_exists($controller)) {
$class = new $controller(); // grab from di cache when we have one
$action = $route['action'];

if (method_exists($class, $action)) {
$class->$action();
}
else {
echo 'We couldn't find action '' . $action . ' in controller '' . $controller . ''';
}
}
else {
echo 'We couldn't find controller '' . $controller . ''';
}
}
}
else {
echo '404 not found';
}
}

}









share|improve this question
























  • _SERVER should be provided from outside. What if action shoul accept parameters?
    – Vladimir Vukanac
    yesterday















up vote
1
down vote

favorite












Before I start writing my first MVC framework, I want to improve my code quality as much as I can, can anyone give me some constructive criticism on how I can improve this?



It is a simple router, built for simple use. It should be pretty simple what's going on, and the usage should be easy to picture. It's nothing major but works well for simple functionality using it.



<?php

class Router {

public $routes = ;
public $routeMethods = ;

public function get($route, $settings) {
$this->add($route, $settings, ['GET']);
}

public function post($route, $settings) {
$this->add($route, $settings, ['POST']);
}

public function add($route, $settings, $methods) {
$this->routes[$route] = $settings;
$this->routeMethods[$route] = $methods;
}

public function dispatch() {
$requestUrl = $_SERVER['QUERY_STRING'];

if (array_key_exists($requestUrl, $this->routes)) {
$route = $this->routes[$requestUrl];
$methods = $this->routeMethods[$requestUrl];
$method = $_SERVER['REQUEST_METHOD'];

if (!in_array($method, $methods)) {
echo 'Method ' . $method . ' not allowed.';
}
else {
$controller = $route['controller'];

if (class_exists($controller)) {
$class = new $controller(); // grab from di cache when we have one
$action = $route['action'];

if (method_exists($class, $action)) {
$class->$action();
}
else {
echo 'We couldn't find action '' . $action . ' in controller '' . $controller . ''';
}
}
else {
echo 'We couldn't find controller '' . $controller . ''';
}
}
}
else {
echo '404 not found';
}
}

}









share|improve this question
























  • _SERVER should be provided from outside. What if action shoul accept parameters?
    – Vladimir Vukanac
    yesterday













up vote
1
down vote

favorite









up vote
1
down vote

favorite











Before I start writing my first MVC framework, I want to improve my code quality as much as I can, can anyone give me some constructive criticism on how I can improve this?



It is a simple router, built for simple use. It should be pretty simple what's going on, and the usage should be easy to picture. It's nothing major but works well for simple functionality using it.



<?php

class Router {

public $routes = ;
public $routeMethods = ;

public function get($route, $settings) {
$this->add($route, $settings, ['GET']);
}

public function post($route, $settings) {
$this->add($route, $settings, ['POST']);
}

public function add($route, $settings, $methods) {
$this->routes[$route] = $settings;
$this->routeMethods[$route] = $methods;
}

public function dispatch() {
$requestUrl = $_SERVER['QUERY_STRING'];

if (array_key_exists($requestUrl, $this->routes)) {
$route = $this->routes[$requestUrl];
$methods = $this->routeMethods[$requestUrl];
$method = $_SERVER['REQUEST_METHOD'];

if (!in_array($method, $methods)) {
echo 'Method ' . $method . ' not allowed.';
}
else {
$controller = $route['controller'];

if (class_exists($controller)) {
$class = new $controller(); // grab from di cache when we have one
$action = $route['action'];

if (method_exists($class, $action)) {
$class->$action();
}
else {
echo 'We couldn't find action '' . $action . ' in controller '' . $controller . ''';
}
}
else {
echo 'We couldn't find controller '' . $controller . ''';
}
}
}
else {
echo '404 not found';
}
}

}









share|improve this question















Before I start writing my first MVC framework, I want to improve my code quality as much as I can, can anyone give me some constructive criticism on how I can improve this?



It is a simple router, built for simple use. It should be pretty simple what's going on, and the usage should be easy to picture. It's nothing major but works well for simple functionality using it.



<?php

class Router {

public $routes = ;
public $routeMethods = ;

public function get($route, $settings) {
$this->add($route, $settings, ['GET']);
}

public function post($route, $settings) {
$this->add($route, $settings, ['POST']);
}

public function add($route, $settings, $methods) {
$this->routes[$route] = $settings;
$this->routeMethods[$route] = $methods;
}

public function dispatch() {
$requestUrl = $_SERVER['QUERY_STRING'];

if (array_key_exists($requestUrl, $this->routes)) {
$route = $this->routes[$requestUrl];
$methods = $this->routeMethods[$requestUrl];
$method = $_SERVER['REQUEST_METHOD'];

if (!in_array($method, $methods)) {
echo 'Method ' . $method . ' not allowed.';
}
else {
$controller = $route['controller'];

if (class_exists($controller)) {
$class = new $controller(); // grab from di cache when we have one
$action = $route['action'];

if (method_exists($class, $action)) {
$class->$action();
}
else {
echo 'We couldn't find action '' . $action . ' in controller '' . $controller . ''';
}
}
else {
echo 'We couldn't find controller '' . $controller . ''';
}
}
}
else {
echo '404 not found';
}
}

}






php mvc url






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









200_success

127k15148412




127k15148412










asked 2 days ago









Beefo

312




312












  • _SERVER should be provided from outside. What if action shoul accept parameters?
    – Vladimir Vukanac
    yesterday


















  • _SERVER should be provided from outside. What if action shoul accept parameters?
    – Vladimir Vukanac
    yesterday
















_SERVER should be provided from outside. What if action shoul accept parameters?
– Vladimir Vukanac
yesterday




_SERVER should be provided from outside. What if action shoul accept parameters?
– Vladimir Vukanac
yesterday










2 Answers
2






active

oldest

votes

















up vote
1
down vote














  • set public $routes to private or protected if its jsut an internal resource of this class. Just use public if other classes/code explicitly should call the mothod/property


  • method_exists doesn't check if the method is callable. But that might be important if you execute legacy code

  • Avoid echo 'some text' Better use exceptions and an exception handler

  • If you use if (){} else{} you could think about using the if for the termination condition and the function continues regulary if its ok

  • Your note about the dependency injection cache is good. Keep your idea. You are on the rigth way.

  • I would recommend to use doc-blocks as annotation and for IDE autocompletion for all public functions as well as class properties. This will increase the readability

  • You didn't said which version of PHP you are using. Switch to >= 7.1 because 7.0 will reach its end of life soon. So you should use return types and type hinting






share|improve this answer








New contributor




unherz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    up vote
    0
    down vote













    Expanding on the answer provided by unherz;



    Validate the programmer



    Sometimes we make mistakes so you should check the $settings provided by the programmer are correct as you require them to pass at least two parameters action & controller so I would add a method validateRouteSettings I also implemented unherz answer to show how early returns (exceptions in this case) would look



    Naming



    You call object methods "actions" which is in-correct, should try to be consistent in naming structures



    Any way here an updated implementation



    <?php

    class Router {

    protected $routes = ;
    protected $routeMethods = ;

    public function get(string $route, array $settings) :void {
    $this->add($route, $settings, ['GET']);
    }

    public function post(string $route, array $settings) :void {
    $this->add($route, $settings, ['POST']);
    }

    public function add(string $route, array $settings, array $methods) :void {
    $this->validateRouteSettings($route, $settings);
    $this->routes[$route] = $settings;
    $this->routeMethods[$route] = $methods;
    }

    private function validateRouteSettings(string $route, array $settings) :bool
    {
    if(!isset($settings["controller"])){
    throw new Exception("Missing controller for $route", 1);
    }elseif(!isset($settings["method"])){
    throw new Exception("Missing method for $route", 1);
    }

    return true;
    }

    public function dispatch() :void {
    $requestUrl = $_SERVER['QUERY_STRING'];

    if (!array_key_exists($requestUrl, $this->routes)) {
    throw new Exception('404 not found', 1);
    }

    $route = $this->routes[$requestUrl];
    $methods = $this->routeMethods[$requestUrl];
    $method = $_SERVER['REQUEST_METHOD'];

    if (!in_array($method, $methods)) {
    throw new Exception('Method ' . $method . ' not allowed.', 1);
    }

    $controller = $route['controller'];

    if (!class_exists($controller)) {
    throw new Exception('We couldn't find controller '' . $controller . ''', 1);
    }

    $class = new $controller(); // grab from di cache when we have one

    $method = $route['method'];

    if (!method_exists($class, $method)) {
    throw new Exception('We couldn't find method '' . $method . ' in controller '' . $controller . ''', 1);
    }

    $class->$method();
    }
    }





    share|improve this answer





















      Your Answer





      StackExchange.ifUsing("editor", function () {
      return StackExchange.using("mathjaxEditing", function () {
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
      });
      });
      }, "mathjax-editing");

      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "196"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f208658%2fsimple-router-in-php%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote














      • set public $routes to private or protected if its jsut an internal resource of this class. Just use public if other classes/code explicitly should call the mothod/property


      • method_exists doesn't check if the method is callable. But that might be important if you execute legacy code

      • Avoid echo 'some text' Better use exceptions and an exception handler

      • If you use if (){} else{} you could think about using the if for the termination condition and the function continues regulary if its ok

      • Your note about the dependency injection cache is good. Keep your idea. You are on the rigth way.

      • I would recommend to use doc-blocks as annotation and for IDE autocompletion for all public functions as well as class properties. This will increase the readability

      • You didn't said which version of PHP you are using. Switch to >= 7.1 because 7.0 will reach its end of life soon. So you should use return types and type hinting






      share|improve this answer








      New contributor




      unherz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















        up vote
        1
        down vote














        • set public $routes to private or protected if its jsut an internal resource of this class. Just use public if other classes/code explicitly should call the mothod/property


        • method_exists doesn't check if the method is callable. But that might be important if you execute legacy code

        • Avoid echo 'some text' Better use exceptions and an exception handler

        • If you use if (){} else{} you could think about using the if for the termination condition and the function continues regulary if its ok

        • Your note about the dependency injection cache is good. Keep your idea. You are on the rigth way.

        • I would recommend to use doc-blocks as annotation and for IDE autocompletion for all public functions as well as class properties. This will increase the readability

        • You didn't said which version of PHP you are using. Switch to >= 7.1 because 7.0 will reach its end of life soon. So you should use return types and type hinting






        share|improve this answer








        New contributor




        unherz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.




















          up vote
          1
          down vote










          up vote
          1
          down vote










          • set public $routes to private or protected if its jsut an internal resource of this class. Just use public if other classes/code explicitly should call the mothod/property


          • method_exists doesn't check if the method is callable. But that might be important if you execute legacy code

          • Avoid echo 'some text' Better use exceptions and an exception handler

          • If you use if (){} else{} you could think about using the if for the termination condition and the function continues regulary if its ok

          • Your note about the dependency injection cache is good. Keep your idea. You are on the rigth way.

          • I would recommend to use doc-blocks as annotation and for IDE autocompletion for all public functions as well as class properties. This will increase the readability

          • You didn't said which version of PHP you are using. Switch to >= 7.1 because 7.0 will reach its end of life soon. So you should use return types and type hinting






          share|improve this answer








          New contributor




          unherz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.










          • set public $routes to private or protected if its jsut an internal resource of this class. Just use public if other classes/code explicitly should call the mothod/property


          • method_exists doesn't check if the method is callable. But that might be important if you execute legacy code

          • Avoid echo 'some text' Better use exceptions and an exception handler

          • If you use if (){} else{} you could think about using the if for the termination condition and the function continues regulary if its ok

          • Your note about the dependency injection cache is good. Keep your idea. You are on the rigth way.

          • I would recommend to use doc-blocks as annotation and for IDE autocompletion for all public functions as well as class properties. This will increase the readability

          • You didn't said which version of PHP you are using. Switch to >= 7.1 because 7.0 will reach its end of life soon. So you should use return types and type hinting







          share|improve this answer








          New contributor




          unherz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer






          New contributor




          unherz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered yesterday









          unherz

          1113




          1113




          New contributor




          unherz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          unherz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          unherz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.
























              up vote
              0
              down vote













              Expanding on the answer provided by unherz;



              Validate the programmer



              Sometimes we make mistakes so you should check the $settings provided by the programmer are correct as you require them to pass at least two parameters action & controller so I would add a method validateRouteSettings I also implemented unherz answer to show how early returns (exceptions in this case) would look



              Naming



              You call object methods "actions" which is in-correct, should try to be consistent in naming structures



              Any way here an updated implementation



              <?php

              class Router {

              protected $routes = ;
              protected $routeMethods = ;

              public function get(string $route, array $settings) :void {
              $this->add($route, $settings, ['GET']);
              }

              public function post(string $route, array $settings) :void {
              $this->add($route, $settings, ['POST']);
              }

              public function add(string $route, array $settings, array $methods) :void {
              $this->validateRouteSettings($route, $settings);
              $this->routes[$route] = $settings;
              $this->routeMethods[$route] = $methods;
              }

              private function validateRouteSettings(string $route, array $settings) :bool
              {
              if(!isset($settings["controller"])){
              throw new Exception("Missing controller for $route", 1);
              }elseif(!isset($settings["method"])){
              throw new Exception("Missing method for $route", 1);
              }

              return true;
              }

              public function dispatch() :void {
              $requestUrl = $_SERVER['QUERY_STRING'];

              if (!array_key_exists($requestUrl, $this->routes)) {
              throw new Exception('404 not found', 1);
              }

              $route = $this->routes[$requestUrl];
              $methods = $this->routeMethods[$requestUrl];
              $method = $_SERVER['REQUEST_METHOD'];

              if (!in_array($method, $methods)) {
              throw new Exception('Method ' . $method . ' not allowed.', 1);
              }

              $controller = $route['controller'];

              if (!class_exists($controller)) {
              throw new Exception('We couldn't find controller '' . $controller . ''', 1);
              }

              $class = new $controller(); // grab from di cache when we have one

              $method = $route['method'];

              if (!method_exists($class, $method)) {
              throw new Exception('We couldn't find method '' . $method . ' in controller '' . $controller . ''', 1);
              }

              $class->$method();
              }
              }





              share|improve this answer

























                up vote
                0
                down vote













                Expanding on the answer provided by unherz;



                Validate the programmer



                Sometimes we make mistakes so you should check the $settings provided by the programmer are correct as you require them to pass at least two parameters action & controller so I would add a method validateRouteSettings I also implemented unherz answer to show how early returns (exceptions in this case) would look



                Naming



                You call object methods "actions" which is in-correct, should try to be consistent in naming structures



                Any way here an updated implementation



                <?php

                class Router {

                protected $routes = ;
                protected $routeMethods = ;

                public function get(string $route, array $settings) :void {
                $this->add($route, $settings, ['GET']);
                }

                public function post(string $route, array $settings) :void {
                $this->add($route, $settings, ['POST']);
                }

                public function add(string $route, array $settings, array $methods) :void {
                $this->validateRouteSettings($route, $settings);
                $this->routes[$route] = $settings;
                $this->routeMethods[$route] = $methods;
                }

                private function validateRouteSettings(string $route, array $settings) :bool
                {
                if(!isset($settings["controller"])){
                throw new Exception("Missing controller for $route", 1);
                }elseif(!isset($settings["method"])){
                throw new Exception("Missing method for $route", 1);
                }

                return true;
                }

                public function dispatch() :void {
                $requestUrl = $_SERVER['QUERY_STRING'];

                if (!array_key_exists($requestUrl, $this->routes)) {
                throw new Exception('404 not found', 1);
                }

                $route = $this->routes[$requestUrl];
                $methods = $this->routeMethods[$requestUrl];
                $method = $_SERVER['REQUEST_METHOD'];

                if (!in_array($method, $methods)) {
                throw new Exception('Method ' . $method . ' not allowed.', 1);
                }

                $controller = $route['controller'];

                if (!class_exists($controller)) {
                throw new Exception('We couldn't find controller '' . $controller . ''', 1);
                }

                $class = new $controller(); // grab from di cache when we have one

                $method = $route['method'];

                if (!method_exists($class, $method)) {
                throw new Exception('We couldn't find method '' . $method . ' in controller '' . $controller . ''', 1);
                }

                $class->$method();
                }
                }





                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Expanding on the answer provided by unherz;



                  Validate the programmer



                  Sometimes we make mistakes so you should check the $settings provided by the programmer are correct as you require them to pass at least two parameters action & controller so I would add a method validateRouteSettings I also implemented unherz answer to show how early returns (exceptions in this case) would look



                  Naming



                  You call object methods "actions" which is in-correct, should try to be consistent in naming structures



                  Any way here an updated implementation



                  <?php

                  class Router {

                  protected $routes = ;
                  protected $routeMethods = ;

                  public function get(string $route, array $settings) :void {
                  $this->add($route, $settings, ['GET']);
                  }

                  public function post(string $route, array $settings) :void {
                  $this->add($route, $settings, ['POST']);
                  }

                  public function add(string $route, array $settings, array $methods) :void {
                  $this->validateRouteSettings($route, $settings);
                  $this->routes[$route] = $settings;
                  $this->routeMethods[$route] = $methods;
                  }

                  private function validateRouteSettings(string $route, array $settings) :bool
                  {
                  if(!isset($settings["controller"])){
                  throw new Exception("Missing controller for $route", 1);
                  }elseif(!isset($settings["method"])){
                  throw new Exception("Missing method for $route", 1);
                  }

                  return true;
                  }

                  public function dispatch() :void {
                  $requestUrl = $_SERVER['QUERY_STRING'];

                  if (!array_key_exists($requestUrl, $this->routes)) {
                  throw new Exception('404 not found', 1);
                  }

                  $route = $this->routes[$requestUrl];
                  $methods = $this->routeMethods[$requestUrl];
                  $method = $_SERVER['REQUEST_METHOD'];

                  if (!in_array($method, $methods)) {
                  throw new Exception('Method ' . $method . ' not allowed.', 1);
                  }

                  $controller = $route['controller'];

                  if (!class_exists($controller)) {
                  throw new Exception('We couldn't find controller '' . $controller . ''', 1);
                  }

                  $class = new $controller(); // grab from di cache when we have one

                  $method = $route['method'];

                  if (!method_exists($class, $method)) {
                  throw new Exception('We couldn't find method '' . $method . ' in controller '' . $controller . ''', 1);
                  }

                  $class->$method();
                  }
                  }





                  share|improve this answer












                  Expanding on the answer provided by unherz;



                  Validate the programmer



                  Sometimes we make mistakes so you should check the $settings provided by the programmer are correct as you require them to pass at least two parameters action & controller so I would add a method validateRouteSettings I also implemented unherz answer to show how early returns (exceptions in this case) would look



                  Naming



                  You call object methods "actions" which is in-correct, should try to be consistent in naming structures



                  Any way here an updated implementation



                  <?php

                  class Router {

                  protected $routes = ;
                  protected $routeMethods = ;

                  public function get(string $route, array $settings) :void {
                  $this->add($route, $settings, ['GET']);
                  }

                  public function post(string $route, array $settings) :void {
                  $this->add($route, $settings, ['POST']);
                  }

                  public function add(string $route, array $settings, array $methods) :void {
                  $this->validateRouteSettings($route, $settings);
                  $this->routes[$route] = $settings;
                  $this->routeMethods[$route] = $methods;
                  }

                  private function validateRouteSettings(string $route, array $settings) :bool
                  {
                  if(!isset($settings["controller"])){
                  throw new Exception("Missing controller for $route", 1);
                  }elseif(!isset($settings["method"])){
                  throw new Exception("Missing method for $route", 1);
                  }

                  return true;
                  }

                  public function dispatch() :void {
                  $requestUrl = $_SERVER['QUERY_STRING'];

                  if (!array_key_exists($requestUrl, $this->routes)) {
                  throw new Exception('404 not found', 1);
                  }

                  $route = $this->routes[$requestUrl];
                  $methods = $this->routeMethods[$requestUrl];
                  $method = $_SERVER['REQUEST_METHOD'];

                  if (!in_array($method, $methods)) {
                  throw new Exception('Method ' . $method . ' not allowed.', 1);
                  }

                  $controller = $route['controller'];

                  if (!class_exists($controller)) {
                  throw new Exception('We couldn't find controller '' . $controller . ''', 1);
                  }

                  $class = new $controller(); // grab from di cache when we have one

                  $method = $route['method'];

                  if (!method_exists($class, $method)) {
                  throw new Exception('We couldn't find method '' . $method . ' in controller '' . $controller . ''', 1);
                  }

                  $class->$method();
                  }
                  }






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 13 hours ago









                  Dan

                  433311




                  433311






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Code Review Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      Use MathJax to format equations. MathJax reference.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f208658%2fsimple-router-in-php%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Ellipse (mathématiques)

                      Quarter-circle Tiles

                      Mont Emei