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 に答える