note 26377 deleted from keyword.extends by danbrown
| From: | danbrown@php.net | Date: | Wed, 17 Jun 2009 19:05:56 +0000 |
| Subject: | note 26377 deleted from keyword.extends by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-157033@lists.php.net to get a copy of this message | ||
Note Submitter: kimh216 at hotmail dot com
----
I made some change...
If you don't want to call parent::callClass('A') on the every function which have to
call it's parent's method.
//multipleInheritance
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
{
var $a;
var $b;
function C()
{
//global $a,$b;
$this->a = parent::callClass('A');//no effect
$this->b = parent::callClass('B');//no effect
}
function insideA()
{
// global $a,$b;
$this->a->insideA();
}
function insideB()
{
//global $a,$b;
$this->b->insideB();
}
function insideC()
{
echo("I'm inside C!<BR>");
}
}
$c = new C();
$c->insideA();
$c->insideB();
$c->insideC();