parent and grandparent functions
| From: | Lenar L�hmus | Date: | Wed, 20 Jun 2001 08:34:49 +0000 |
| Subject: | parent and grandparent functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-57346@lists.php.net to get a copy of this message | ||
Hello,
Sorry to write in dev, but i consider this a weakness of php. Something
needs to be changed.
Ok, maybe thereis a solution right now existing in PHP, but i'm unaware of
it.
Skip to the problem....
I have three classes:
class a {
function make() {
// some code
}
}
class b extends a {
function make() {
// some code
parent::make();
}
}
class c extends b {
function make() {
// some code
parent::make();
}
}
now the class 'c' is instantiated and the member function 'make' is called.
All works up to the point where 'b'::make calls parent::make().
It seems to call itself :(. I can understand this is logical behaviour since
it's still an instance of class c,
so parent:: is still b::, but how should I call that grandparent's make()???
This doesn't seem like a good OOP.
For example delphi's 'inherited' works relative to the class it's used in
and it is way more useful than php's parent::.
is there any elegant solution(s) to my problem?
Lenar Lõhmus