Multiple Inheritance Emulation

From: Date: Fri, 27 Sep 2002 18:40:23 +0000
Subject: Multiple Inheritance Emulation
Groups: php.general 
Request: Send a blank email to php-general+get-117881@lists.php.net to get a copy of this message
I don't fully understand OOP, so my snippet might be wrong. But I need to emulate Multiple Inheritance for a script, so I've made the following, which I ask for opinions since I am not so sure if it will always work. 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(); -- And it echo: I'm inside A! I'm inside B! -- Julio Nobrega http://gnet.inerciasensorial.com.br

« previous php.general (#117881) next »