$a = &$b
とPHP OOP$a = $b
の違いは何ですか? クラスのインスタンスです。$b = clone $a
$a
2222 次
3 に答える
9
// $a is a reference of $b, if $a changes, so does $b.
$a = &$b;
// assign $b to $a, the most basic assign.
$a = $b;
// This is for object clone. Assign a copy of object `$b` to `$a`.
// Without clone, $a and $b has same object id, which means they are pointing to same object.
$a = clone $b;
References、Object Cloningで詳細を確認してください。
于 2012-06-25T07:08:34.893 に答える
0
// $a has same object id as $b. if u set $b = NULL, $a would be still an object
$a = $b;
// $a is a link to $b. if u set $b = NULL, $a would also become NULL
$a = &$b;
// clone $b and store to $a. also __clone method of $b will be executed
$a = clone $b;
于 2012-06-25T07:15:14.143 に答える
-1
ZVAL 構造とは何か、ZVAL 構造の refcount,is_ref とは何かを知らなかった場合は、PHP のガベージ コレクションに少し時間をかけてください。
于 2012-06-25T07:36:03.240 に答える