Q:

How to get PHP parent functions to reference overridden functions in child if they exist?

Given the following Code:
class A {
    public static function one() {
        return "results from Parent::one";
    }
    public function two() {
        return "Parent::two got info: ".self::one();
    }
}

class B extends A {
    public static function one() {
        return "results from child::one";
    }
}

$a=new B();
print "calling two I get: ". $a->two()."\n";
print "calling one I get: ". $a->one()."\n\n";

I get the following results:

calling two I get: Parent::two got info: results from Parent::one
calling one I get: results from child::one

I expected the first result above to be:

calling two I get: Parent::two got info: results from child::one

It seems that while overrides work, they do not work recursively, only in a direct call from the child.  Is there a way to assure that when a child class accesses a method from the parent, the parent methods reference the overridden methods when they exist?
Thanks

A:

You're probably looking for late bindings. Simply changing from self::one() to static::one() should do the trick.
return "Parent::two got info: ".static::one();

