Re: Question regarding constructors and child classes

From: Date: Thu, 18 Nov 2004 02:49:54 +0000
Subject: Re: Question regarding constructors and child classes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-202372@lists.php.net to get a copy of this message
Hi, Comment inline On Wed, 17 Nov 2004 20:19:01 -0600, Brent Clements <bclem@imaginative-enterprises.com> wrote: > > <?php > > class foo { > > function foo () { > > echo "constructed!"; > > } > > } > > class childFoo extends foo { > > function childFoo() { > // here you should call the parent constructor: parent::foo() // also you could do this other way (I prefer the one above): $this->foo() > echo "constructed also!"; > > } > > } > > $a = new childFoo(); > > ?> > > Is there any way to run both the parent and child constructor? http://www.php.net/manual/en/language.oop.constructor.php http://www.php.net/manual/en/language.oop5.decon.php Regards, Jordi.

« previous php.general (#202372) next »