Jochem Maas wrote:
another solution for the OP might be (although I think it goes against all
design principles):

class A {
  function foo() {
    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();


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?

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

Reply via email to