Re: unset( $anobject) does not invoce __destruct()
| From: | Ralph Deffke | Date: | Mon, 24 Aug 2009 13:13:49 +0000 |
| Subject: | Re: unset( $anobject) does not invoce __destruct() | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-297118@lists.php.net to get a copy of this message | ||
that is correct and that is the problem, and even that is not all !!!
try this
<?php
abstract class a {
public function __construct(){
echo "constructing....<br>";
}
public function __detruct(){
echo "destructing....<br>";
}
}
class b extends a{
}
$c = new b();
unset( $c );
?>
the constructor is inherited, the destructor not !!
PHP 5.2.9-1 and
PHP 5.3.0 behave the same
las trampas de la vida
ralph_deffke@yahoo.de
"Stuart" <stuttle@gmail.com> wrote in message
news:a5f019de0908240606x5fdca70bkb31dd32b072e52b6@mail.gmail.com...
> 2009/8/24 kranthi <kranthi117@gmail.com>:
> > unset($obj) always calls the __destruct() function of the class.
> >
> > in your case clearly you are missing something else. Probably
> > unset($anobject) is not being called at all ?
>
> That's not entirely correct. PHP uses reference counting, so if
> unsetting a variable did not cause the object to be destructed then
> it's highly likely that there is another variable somewhere that is
> holding a reference to that object.
>
> -Stuart
>
> --
> http://stut.net/