是什么意思$ this-> $ object =& php中的新$ class

时间:2012-07-30 14:26:01

标签: php oop

  

可能重复:
  Reference assignment operator in php =&

我想创建一个博客,这是控制器文件,但我不明白这一行

$this->$model =& new $model; 这行怎么办?     

    protected $_model;
    protected $_controller;
    protected $_action;
    protected $_template;

     function __construct($model, $controller, $action) {

        $this->_controller = $controller;
    $this->_action = $action;
    $this->_model = $model;

    $this->$model =& new $model;
    $this->_template =& new Template($controller,$action);

}

function set($name,$value) {
    $this->_template->set($name,$value);
}

function __destruct() {
        $this->_template->render();
}

}

2 个答案:

答案 0 :(得分:2)

插入$model变量。说它是“欢迎”。这被内插到

$this->Welcome = & new Welcome;

&在PHP 5中什么都不做,应该删除。在PHP 4中,成员必须维护对对象实例的引用。

答案 1 :(得分:0)

这一行意味着它的开发人员不知道PHP5中的内存(__ destruct仅在PHP5中)是如何工作的。