new operator and reference error

后端 未结 3 1816
陌清茗
陌清茗 2021-01-28 09:50
 $class_name = \'MDB2_Statement_\'.$this->phptype;
        $statement = null;
        $obj =& new $class_name($this, $statement, $positions, $query, $types, $resu         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-28 10:11

    Why do you even use the reference operator with objects? A object is placed in the memory and all variables bound to it will change its memory.

    In other words

    $a1 = new stdClass;
    $a2 = $a1;
    

    would have the same affect as:

    $a1 = 1000;
    $a2 = &$a1;
    

提交回复
热议问题