www.xx.pl/gallery/show/12
wyciągnąć i odpalić po kolei:
kontroler: gallery
metoda: show
parametr: 12
do tej pory osiągnąłem takie coś:
<?php //include('config.php'); include('application/SimpleUrl.class.php'); function classAutoloader($class) { include ('controllers/'.$class.'.controller.php'); } spl_autoload_register('classAutoloader'); $url = new SimpleUrl('/labs/mvc3'); $url_controller = $url->segment(1); $url_action = $url->segment(2); $url_param = $url->segment(3); if ($url_controller) { $controller = new $url_controller; if ($url_action && $url_param) { $controller->$url_action($url_param); } elseif ($url_action) { $controller->$url_action(); } } else { $controller = new Home; } ?>
oraz simpleUrl:
<?php class SimpleUrl { var $site_path; public function __construct($site_path) { $this->site_path = $this->removeSlash($site_path); } public function __toString() { return $this->site_path; } private function removeSlash($string) { { } return $string; } public function segment($segment) { { return $url[$segment]; } else { return false; } } } ?>
Teraz to działa, ale tylko jeśli plik nazywa się Home.controller.php, a ja chciałbym zrobić tak:
$controller = new HomeController;
żeby ta część ładowała mi plik Home.controller.php
a w linku wyświetlało się www.xx.pl/home
da się to zrobić ?