<?php
// Connect to the DB Connect Class - Singleton Design Pattern
include 'dbconfig.php';
//Get the request URL and retrieve the Controller and Action
$requestUrl = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$urlParams = explode('/', $requestUrl);
// Here you should probably gather the rest as params
//Call the model
try
{
$modelName = $urlParams[4].'Model';
require_once 'Model/'.$modelName.'.php';
}
catch (Exception $ex)
{
echo "Cannot access the model class!";
}
//Call the controller and action
try
{
$controllerName = strtolower($urlParams[4]).'Controller';
$action = explode("?", $urlParams[5]);
$actionName = $action[0].'Action';
require_once 'Controller/'.$controllerName.'.php';
// Call the action
$controller = new $controllerName;
$controller->$actionName();
}
catch (Exception $ex)
{
echo "Cannot access the controller class!";
}
//Include the View
try
{
include 'View/'.$urlParams[4].'/'.$action[0].'.php';
}
catch (Exception $ex)
{
include 'View/index.php';
}
?>
this is coding for what you have ask