0
MVC 컨트롤러에서 새 모델 객체를 만들려고하지만 페이지가 생성되지 않습니다. 왜 내가 할 수없는 이유가 있니? 확실하게 기존 객체 안에 객체를 생성 할 수 있어야합니까?PHP 새 클래스 객체가 인스턴스화되지 않음
미안하지만 나는 바보처럼 들리지만, 내가 잘못하고있는 것을 설명하는 방법을 모르겠다.
class controller_landing extends controller_base
{
public function __construct($get,$post)
{
parent::__construct($get,$post);
$this->model = new model_landing; <-----problem line here
}
}
abstract class controller_base
{
//store headers
protected $get;
protected $post;
//store layers
protected $view;
protected $model;
protected function __construct($get,$post)
{
//store the header arrays
$this->get = $get;
$this->post = $post;
//preset the view layer as an array
$this->view = array();
}
public function __destruct()
{
//extract variables from the view layer
extract($this->view);
//render the view to the user
require_once('view/'.$this->get['controller'].'_view.php');
}
}
class model_landing extends class_mysqli
{
public function __construct
{
echo "landing model";
}
}
class class_mysqli
{
public function __construct
{
echo "mysqli";
}
}
내가 여기 당신의 문제가 무엇인지 확실히 모르겠어요이 있어야 . 위의 코드는 내 컴퓨터에서 잘 작동하며 뷰어에서 콘텐츠를 출력합니다. 이것은 phpfiddle http://phpfiddle.org/main/code/vhy-ecw에서도 올바르게 작동하는 것으로 보입니다. PHP의 어떤 버전을 사용하고 있습니까? 아마도 error_log가 있으면이를 표시 할 수 있습니까? – tftd
어쩌면 오토로더에 문제가있는 것 같습니다. 어쨌든 –