Beispiel #1
0
 function __construct()
 {
     $url = isset($_GET["url"]) ? $_GET["url"] : null;
     $url = rtrim($url, '/');
     $url = explode('/', $url);
     if (empty($url[0])) {
         // If Empty array then invoke Defualt Home page
         require 'Controller/Home.php';
         $controller = new Home();
         echo "I am here";
         $controller->loadModel("home");
         $controller->index();
         return false;
     }
     $file = 'Controller/' . $url[0] . '.php';
     //Check File Is exist in the Controller
     if (file_exists($file)) {
         require $file;
     } else {
         $this->error();
     }
     $controller = new $url[0]();
     // Home Controller
     $controller->loadModel($url[0]);
     if (isset($url[2])) {
         //Check Function parameter is set in the URL
         $_method_name = 'execute' . $url[1];
         if (method_exists($controller, $_method_name)) {
             $controller->{'execute' . $url[1]}($url[2]);
         } else {
             $this->error();
         }
     } else {
         if (isset($url[1])) {
             $_method_name = 'execute' . $url[1];
             if (method_exists($controller, $_method_name)) {
                 $controller->{'execute' . $url[1]}();
             } else {
                 $this->error();
             }
         } else {
             $controller->index();
         }
     }
 }