[英]php new class object not being instanced
我正在尝试从我的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";
}
}
我不知道,但我认为你缺少括号。 那里
public function __construct
{
echo "landing model";
}
应该
public function __construct()
{
echo "landing model";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.