note 27752 added to keyword.extends
| From: | duda_y at yahoo dot co dot uk | Date: | Tue, 17 Dec 2002 18:42:15 +0000 |
| Subject: | note 27752 added to keyword.extends | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41027@lists.php.net to get a copy of this message | ||
Why should I call parent::callClass()
//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
// can't we write like this?
$this->a =& new A();
$this->b =& new B();
}
function insideA()
{
// global $a,$b;
$this->a->insideA();
}
function insideB()
{
//global $a,$b;
$this->b->insideB();
}
function insideC()
{
echo("I'm inside C!
");
}
}
--
http://www.php.net/manual/en/keyword.extends.php
http://master.php.net/manage/user-notes.php?action=edit+27752
http://master.php.net/manage/user-notes.php?action=delete+27752
http://master.php.net/manage/user-notes.php?action=reject+27752