Re: calling parent class method from the outside

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



admin wrote:
Inside the body of method foo() you can of course use syntax like
parent::foo(). But is there a way to call the parent version of
obj->foo() outside the class? That kind of syntax is allowed in C++, for
example: Aclass a; if (a.Aparent::foo()) ...;

Not sure I get your requirement exactly, but you could try this:

class A
{
    public function foo ()
    {
        // ...
    }
}

class B {
    public parent;

    // Constructor
    public function __construct ()
    {
        $this->parent = new A();
    }
}


// And then...

$b = new B();
$b->parent->foo();

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk
Currently looking for partnerships

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux