Re: unset( $anobject) does not invoce __destruct()

From: Date: Mon, 24 Aug 2009 13:10:17 +0000
Subject: Re: unset( $anobject) does not invoce __destruct()
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-297117@lists.php.net to get a copy of this message
kranthi wrote:
unset($obj) always calls the __destruct() function of the class.
Never calls the dtor. The dtor will be called only when the reference count reaches 0. class c { function __destruct() { echo 'dying !' ; } } $v1 = new c ; $v2 = $v1 ; unset($v1) ; // don't call the dtor unset($v2) ; // call the dtor -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org

« previous php.general (#297117) next »