-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.php
More file actions
34 lines (30 loc) · 747 Bytes
/
Copy pathrouter.php
File metadata and controls
34 lines (30 loc) · 747 Bytes
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
<?php
class Router
{
public $url;
function __construct()
{
if(isset($_GET['url'])){
$this->url=$_GET['url'];
}else{
$this->url='index';
}
}
function yonlendir()
{
$data = explode('/', $this->url);
$function_name = $data[0];
require('controller/home.php');
$controller = new home();
if (method_exists($controller, $function_name)) {
if (!empty($data[1])) {
$gonderilen_deger = $data[1];
$controller->$function_name($gonderilen_deger);
} else {
$controller->$function_name();
}
} else {
include('view/404.php');
}
}
}