はPHPではすべての値はzvalsに格納されています。これらのzvalは実際のデータと型情報を含んでいます。次の例をチェックアウトしてください。
<?php
class O{
public $ppty = "ppty value";
}
$a = new 0; // $a is pointing to zval(class 0) with refcount 1
$b = $a; // $a and $b are pointing to zval(class 0) with refcount 2
$c = $b; // $a, $b and $c are pointing to zval(class 0) with refcount 3
unset($a) // new $b and $c are pointing to zval(class 0) with refcount 2
// until the refcount is greater then the 0 the destructor will not called
?>
今現在のプロセスが終了したら、それは破壊を呼び出します//
<?php
function f1(){
$o1 = new O(); // refcount = 1
return $o1;
}
// now you are returning the object in function f1 and so,
// $o1 is gone after the function scope but the func f1 is now pointing the its reference.
var_dump(f1())
**Result:**
object(O)[15]
public 'ppty' => string 'ppty value' (length=10)
あなたの例に来る次の例
<?php
$a = new 0; // $a is pointing to zval(class 0) with refcount 1
unset($a) // here refcount is 0 and destruct will be called
?>
を見てみましょう。
オブジェクトの有効期間は可変期間に接続されていません。 –
@ IgnacioVazquez-Abramsこれについて私に言及できる資料はありますか? –