Postingan lainnya
Error require_once homeController
<?php
class Route {
protected $controller = 'homeController';
protected $method = 'index';
protected $params = [];
public function __construct(){
if (isset($_GET['url'])) {
$url = explode('/', filter_var( trim($_GET['url']), FILTER_SANITIZE_URL ));
}
$url[0] = $url[0] . 'Controller';
//mengecek file controller
if( file_exists('../app/Controllers/'.$url[0].'.php') ){
$this->controller = $url[0];
}
require_once '../app/Controllers/'. $this->controller . '.php';
$this->controller = new $this->controller;
if (isset($url[1])){
if(method_exists($this->controller, $url[1])){
$this->method = $url[1];
}
}
unset($url[0]);
unset($url[1]);
$this->params = $url;
call_user_func_array( [$this->controller, $this->method], $params);
}
}
?>
Screenshot from 2022-01-22 08-56-31.png
Sudah saya sesuaikan dengan tutorial, akan tetapi tetap muncul error pada require_once pada line 22. Mohon solusinya, terima kasih
0
1 Jawaban:
<div>Berarti file controllernya ga ada... atau ga ditemukan. Coba cek dir yang berisi file controllernya tersebut.</div>
1