Re: calling parent class method from the outside
| From: | Richard Heyes | Date: | Mon, 02 Jul 2007 15:00:58 +0000 |
| Subject: | Re: calling parent class method from the outside | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258042@lists.php.net to get a copy of this message | ||
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