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

From: Date: Mon, 24 Aug 2009 19:46:56 +0000
Subject: Re: unset( $anobject) does not invoce __destruct()
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-297141@lists.php.net to get a copy of this message
I dont agree, and as u see in my snipped code it works fine. in an abstract class u can define an implementation to define some basic things a overwriting function in an extending class has to take care of as well. this includes specialy magic functions. thats what they are made for. may be you talk about interfaces ? "hack988 hack988" <hack988@dev.htwap.com> wrote in message news:4d03254c0908241122r5b6d1c3csc06ec475a0797218@mail.gmail.com... > see http://cn.php.net/manual/en/language.oop5.abstract.php > PHP 5 introduces abstract classes and methods. It is not allowed to > create an instance of a class that has been defined as abstract. Any > class that contains at least one abstract method must also be > abstract. Methods defined as abstract simply declare the method's > signature they cannot define the implementation. > > You make misconception understand for abstract class,:(, correct code is: > abstract class a { > abstract public function __construct(){ > > } > abstract public function __destruct(){ > > } > } > > class b extends a{ > public function __construct(){ > echo "constructing....<br>"; > } > public function __destruct(){ > echo "destructing....<br>"; > } > } > > $c = new b(); > unset($c); > > if you want to make it work correctly that you want,plase change code to follow > class c { > public function __construct(){ > echo "constructing....<br/>"; > } > public function __destruct(){ > echo "destructing....<br/>"; > } > } > > class d extends c{ > > } > $e = new d(); > unset($e);

« previous php.general (#297141) next »