Re: calling parent class method from the outside
| From: | admin | Date: | Mon, 02 Jul 2007 19:41:28 +0000 |
| Subject: | Re: calling parent class method from the outside | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258053@lists.php.net to get a copy of this message | ||
Jochem Maas wrote:
another solution for the OP might be (although I think it goes against all design principles): class A { function foo() {Barring the s/parent/get_parent_class/ the idea is really really cute, thanks. Beautiful. Heck, maybe I'll even hack the code to do it like that... after some grace period. P.S.: I thought calling array('classname', 'method') only worked for static methods? It turns out there's an implied $this being passed around?echo "achoo\n";} } class B extends A { function foo() {echo "cough\n";} function __call($meth, $args) {$func = array(parent, strtolower(str_replace("parent","", $meth))); if (is_callable($func)) return call_user_func_array($func, $args);} } $b = new B; $b->foo(); $b->parentFoo();