Здравейте, имам следната ситуация. Работя с чисти Url-и от типа на /localhost/Site/controller/method/params/. Когато напиша в Url-а контролер или метод които не съществуват, редиректвам към ерор страница. Обаче ако напиша контролер примерно така index asd(със space между тях) ми вади класическа грешка. Как мога да прихвана ситуацията, за да си визуализирам ерор страницата.
Код:
$this->_params = explode('/', $this->_URI);
if ($this->_params[0]) {
$this->_controller = strtolower($this->_params[0]);
if(is_file($this->_controller) ){
$app = \application\App::getInstance()->displayError(404);
exit;
}
if ($this->_params[1]) {
$this->_method = strtolower($this->_params[1]);
if (!method_exists($this->_namespace . '\\' . $this->_controller, $this->_method)) {
$app = \application\App::getInstance()->displayError(404);
exit;
}
unset($this->_params[0], $this->_params[1]);
} else {
$this->_method = strtolower($this->_config->app_config_file['default_method']);
}
} else {
$this->_controller = strtolower($this->_config->app_config_file['default_controller']);
$this->_method = strtolower($this->_config->app_config_file['default_method']);
}
$this->_file = $this->_namespace . '\\' . ucfirst($this->_controller);
$this->_loadController = new $this->_file();
$this->_loadController->{$this->_method}();