php include application components controller php include application

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
include 'application/components/controller.php';
include 'application/components/model.php';
include 'application/components/view.php';
$req = split('/', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
$req[1] = $req[1] ? $req[1] : 'home';
$req[2] = $req[2] ? $req[2] :'index';
if (!file_exists('application/controllers/' . $req[1] . '.php')) {
exit;
}
if (!file_exists('application/models/' . $req[1] . '.php')) {
exit;
}
include 'application/models/' . $req[1] . '.php';
$model_name = 'model_' . $req[1];
$model = new $model_name();
include 'application/controllers/' . $req[1] . '.php';
$controller_name = 'controller_' . $req[1];
$controller = new $controller_name($model);
if (!method_exists($controller, 'action_' . $req[2])) {
exit;
}
$action_name = 'action_' . $req[2];
$controller->$action_name();
$view = new view($model);
$view->output();