__deconstruct不写会话变量

时间:2013-01-04 18:32:32

标签: php yii destructor

我有一个包含此功能的购物车库。从documentation开始说明:PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as there are no other references to a particular object, or in any order during the shutdown sequence.

我不确定为什么没有召唤这个。任何人都可以对此有所了解吗?

public function __deconstruct () {
    Yii::app()->session->add('cart', $this->order);
}

1 个答案:

答案 0 :(得分:3)

__destruct而非__deconstruct

http://php.net/manual/en/language.oop5.decon.php