calling parent class method from the outside
| From: | admin | Date: | Mon, 02 Jul 2007 14:15:36 +0000 |
| Subject: | calling parent class method from the outside | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-258036@lists.php.net to get a copy of this message | ||
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()) ...;
Some contrived example to illustrate the point:
class AParent {
public function foo() { .. }
}
class A extends AParent {
public function foo() {
doit($this, __CLASS__, __FUNCTION__);} } function doit($obj, $classname, $funcname) { if (...)
// $obj->classname_parent::$funcname();} Thanks.