Próbuje napisać klasę Router do swojego systemu, jednak chyba coś mi nie wychodzi. Proszę spojrzeć.
<?php class Router { private $url; public function __construct() { $this->url = $_SERVER['PATH_INFO']; $this->getParams(); } // pobiera nazwę serwera public function getServerName() { return $_SERVER['HTTP_HOST']; } public function getParams() { } // pobiera parametr o wyznaczonym id public function getParam($id) { } // pobiera nazwę modułu np. news, page, download public function getModule() { return $this->getParam(0); } // pobiera nazwę akcji np. edit, add lub delete public function getAction() { return $this->getParam(1); } // tworzy adres URL np. wpisując createUrl('news/edit/2'); otrzymamy domena.com/index.php/news/edit/2 public function createUrl($params) { return $this->getServerName().'/index.php/'.$params; } } ?>
Czy dobrze zrozumiałem założenie tej klasy?