Re: Destructors in local scope

From: Date: Wed, 17 Apr 2002 08:18:47 +0000
Subject: Re: Destructors in local scope
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-5593@lists.php.net to get a copy of this message
On Wed, 2002-04-17 at 06:34, Brent Cook wrote: > In the following code block: > > <?php > > class Mouse extends PEAR > { > _Mouse { echo "squeak!\n"; } > } > > function cat () > { > $mouse = new Mouse(); > } > > cat(); > > ?> > > Should _Mouse be called when leaving cat() ? Destructors in PEAR are only > called when PHP shuts down, right? This is the behavior that I am seeing, > I just wanted to know if it is correct to expect it. PEAR "destructors" won't work unless you have explicitly called the PEAR class's constructor, so you should do this: class Mouse extends PEAR { function Mouse() { $this->PEAR(); } function _Mouse() { echo "squeak!\n"; } } - Stig

« previous php.pear.dev (#5593) next »