/
App.php
executable file
·62 lines (34 loc) · 960 Bytes
/
App.php
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
class App
{
protected $controller = "pages";
protected $method = "home";
protected $params = [];
function __construct()
{
# code...
$url =$this->URLparser();
if (file_exists("../app/controllers/".$url[0].'.php')) {
$this->controller = $url[0];
unset($url[0]);
# code...
}
require_once "../app/controllers/".$this->controller.'.php';
$this->controller = new $this->controller;
if (isset($url[1])) {
// die($url[1]);
if (method_exists($this->controller,$url[1])) {
$this->method = $url[1];
# code...
unset($url[1]);
}
}
$this->params = $url ? array_values($url) : [];
call_user_func_array( [$this->controller, $this->method], $this->params);
}
public function URLparser(){
if ( isset($_GET['url']) ) {
return explode("/",filter_var(trim($_GET['url'],'/'),FILTER_SANITIZE_URL)) ; # code...
}
}
}