1

可能重复:
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();
}

}
4

2 回答 2

2

$model变量被插值。说“欢迎”。这被内插为

$this->Welcome = & new Welcome;

&PHP 5 中没有任何作用,应该被删除。在 PHP 4 中,成员必须维护对对象实例的引用。

于 2012-07-30T14:28:13.637 回答
0

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

于 2012-07-30T14:48:41.837 回答