0

我正在尝试从我的 mvc 控制器创建一个新的模型对象,但页面没有生成。有什么理由我不能这样做吗?当然,我应该能够在现有对象中创建一个对象吗?

抱歉这么简单,我知道我听起来像个白痴,但我不知道如何解释我做错了什么。

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";
    }
}
4

1 回答 1

2

我不知道,但我认为你缺少括号。那里

public function __construct
{
        echo "landing model";  
}

应该

public function __construct()
{
        echo "landing model";   
}
于 2013-11-03T19:25:59.633 回答