RE: [PHP] parent and grandparent member functions
| From: | Neil Kimber | Date: | Wed, 20 Jun 2001 12:33:56 +0000 |
| Subject: | RE: [PHP] parent and grandparent member functions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-54505@lists.php.net to get a copy of this message | ||
The following should work - although I haven't tried it:
class a {
function make() {
// some code
}
}
class b extends a {
function make() {
// some code
a::make();
}
}
class c extends b {
function make() {
// some code
b::make();
}
}
-----Original Message-----
From: Lenar Lõhmus [mailto:lenar@dotcom.ee]
Sent: 20 June 2001 09:01
To: php-general@lists.php.net
Subject: [PHP] parent and grandparent member functions
Hello,
I hit a wall. No offense, but this OO stuff in PHP is somehat weird, but
skip to the problem.
I have for example 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 way.
is there any elegant soultion(s) to my problem?
Lenar Lõhmus