下面的代码说明了两次调用destruct().我想知道为什么?
class A {
function hi(){ echo 'hi'; }
function __destruct(){
echo 'destroy';
}
}
class B{
public $this_ = '';
function __construct(){
$this->this_ = new A;
}
function __call($method,$params) {
return call_user_func_array(array($this->this_,$method),$params);
}
}
$b = new B;
$b->__destruct();
destroydestroy
编辑
zneak和TomcatExodus都是正确的.如果我只是:
[..code..]
$b = new B;
$b->__destruct();
print 'end of script';
destroyend of scriptdestroy