How is the correct way to call a child class method from a parent class if both are static?
When I use static classes it returns the error "Call to undefined method A::multi()", however when I use non-static methods there is no problem, for example:
//-------------- STATIC ------------------
class A {
public static function calc($a,$b) {
return self::multi($a, $b);
}
}
class B extends A {
public static function multi($a, $b) {
return $a*$b;
}
}
echo B::calc(3,4); //ERROR!!
//-------------- NON-STATIC ----------------
class C {
public function calc($a,$b) {
return $this->multi($a, $b);
}
}
class D extends C {
public function multi($a, $b) {
return $a*$b;
}
}
$D = new D();
echo $D->calc(3,4); // Returns: 12
Is there a way to call a child static method without knowing its class name?