Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- $scriptPath = '/';
- $uri = mb_substr($_SERVER['REQUEST_URI'], mb_strlen($scriptPath));
- $parts = explode('/', $uri);
- $controller = (!empty($parts[0]) ? $parts[0] : 'index');
- $action = (!empty($parts[1]) ? $parts[1] : 'index');
- if (file_exists($_SERVER['DOCUMENT_ROOT'] . $scriptPath . 'controllers/' . $controller . 'Controller.php')) {
- require($_SERVER['DOCUMENT_ROOT'] . $scriptPath . 'controllers/' . $controller . 'Controller.php');
- $class = $controller . 'Controller';
- if (method_exists($class, $action)) {
- $obj = new $class;
- $obj->$action();
- }
- else
- throw new Exception("Undefined action: $action");
- } else {
- throw new Exception("Invalid controller specified: {$class}");
- }
- /**
- #.htaccess
- RewriteEngine on
- RewriteBase /
- RewriteRule .*$ index.php [L]
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement