note 25562 added to keyword.extends
| From: | \ | Date: | Fri, 27 Sep 2002 18:36:14 +0000 |
| Subject: | note 25562 added to keyword.extends | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-37339@lists.php.net to get a copy of this message | ||
Multiple Inheritance is not supported but it is easy to emulate it:
class multipleInheritance
{
function callClass($class_to_call)
{
return new $class_to_call();
}
}
class A
{
function insideA()
{
echo "I'm inside A!<br />";
}
}
class B
{
function insideB()
{
echo "I'm inside B!<br />";
}
}
class C extends multipleInheritance
{
function insideC()
{
$a = parent::callClass('A');
$a->insideA();
$b = parent::callClass('B');
$b->insideB();
}
}
$c = new C();
$c->insideC();
---
This will succesfully echo:
I'm inside A!
I'm inside B!
--
http://www.php.net/manual/en/keyword.extends.php
http://master.php.net/manage/user-notes.php?action=edit+25562
http://master.php.net/manage/user-notes.php?action=delete+25562
http://master.php.net/manage/user-notes.php?action=reject+25562