class Bootstrap{
public $_url;
public $_Controller;
public $_methodName;
public $_ControllerName;
public $_fileExtention = ".php";
public $DefaultPage = ['page','init'];
public $ControllerPath = "Application/Controller/";
public function __construct() {
$this->getURL();
$this->loadController();
$this->callMethod();
}
public function getURL(){
$this->_url = array_filter(explode('/',$_GET['action']));
if(!isset($this->_url[0])){$this->_url[0] = $this->DefaultPage[0];}
}
public function loadController(){
$this->_ControllerName = $this->_url[0];
if(file_exists($this->ControllerPath.$this->_ControllerName.$this->_fileExtention)){
require($this->ControllerPath.$this->_ControllerName.$this->_fileExtention);
if(class_exists($this->_ControllerName)){
$this->_Controller = new $this->_ControllerName();
return $this->_Controller;
}else{ /**echo "burası";*/ }
}else{
require($this->ControllerPath.$this->DefaultPage[0].$this->_fileExtention);
$Pages = $this->DefaultPage[0];
$this->_Controller = new $Pages();
$this->_Controller->notfound();
exit();
}
}
public function callMethod(){
$this->_methodName = $this->_url[1];
$methodName = $this->_methodName;
if(method_exists($this->_Controller,$this->_methodName)){
if(isset($this->_url[2])){
$this->_Controller->$methodName($this->_url[2]);
}else{
$this->_Controller->$methodName();
}
}else{
$DefaultPage = $this->DefaultPage[1];
$this->_Controller->$DefaultPage();
}
}
}Kodları yeniden yazıp sorunu çözdüm sanırım class adını alırken
$thiskullanmadığım için yazdığım sayları tanımıyormuş