Re: [PHP5] Super constructor?

From: Date: Mon, 14 Jun 2004 18:09:36 +0000
Subject: Re: [PHP5] Super constructor?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-188245@lists.php.net to get a copy of this message
If i'm not wrong php has only 1 level of depth for child class. That means you can only extends from 1 level up the class. In your example you have the class OneMore that extends down from the "grandfather" Base. It is not a problem in C++ but should not work in php or either javascript. Am i wrong? Franciccio "Frzzman" <FrzzMan@vnOCzone.com> ha scritto nel messaggio news:20040613063640.21005.qmail@pb1.pair.com... > Hi guys, hey don't laugh at the subject, in fact I don't what to call > it, so let's call it super constructor :D > > Let's see following code... > > class Base > { > __construct() > { > // Do something > } > } > > class One extends Base > { > __construct() > { > // Do nothing > } > } > > class OneMore extends One > { > __construct() > { > // Do things :D > } > } > > So when I create an instance of OneMore class by: > > $OneMoreInstance = new OneMore() > > The __construct() method of class OneMore will be called, not the one of > One and Base, right? > > So is there any way around to make the Base class have a contructor that > will be called everytime one of its child initialize? > > My problem, I want all of the classes in my object are extend from one > base class, so they are all have some common properties and function, > but PHP won't implicit call the contructor (that's the right way)... > btw, in my case, this is bad, as bad as every constructor would be called... > > Well, hope you understand what I'm trying to say...

« previous php.general (#188245) next »