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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to