Re: Class Con- and Destructor Inheritance

From: Date: Sun, 22 Aug 2004 22:12:54 +0000
Subject: Re: Class Con- and Destructor Inheritance
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-194433@lists.php.net to get a copy of this message
On Sun, 22 Aug 2004 13:04:11 +0200, Daniel Schierbeck <dasch@ulmail.net> wrote: > Hello there. I was experimenting a bit with the constructors and > destructors, and found that this code: > > <?php > > class First > { > public function __construct () > { > echo "Hello, World!\n"; > } > > public function __destruct () > { > echo "Goodbye, World!\n"; > } > } > > class Second extends First > { > > } > > $second = new Second; > > ?> > > Outputs > > Hello, World! > Goodbye, World! > > , yet the PHP manual > (http://www.php.net/manual/en/language.oop5.decon.php) says: > > Note: Parent constructors are not called implicitly. In order > to run a parent constructor, a call to parent::__construct() is > required. > > Is this an error in the manual or in PHP itself? Should I report it > somewhere? > No, this is not a bug. This means that if you define a new constructor / destructor, the parent class's won't be called unless you put it in the new ones. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin--

« previous php.general (#194433) next »