I tried passing this question to SO, but still not getting it.
<?php
class A {
public function __call($method, $parameters) {
echo "I'm the __call() magic method".PHP_EOL;
}
public static function __callStatic($method, $parameters) {
echo "I'm the __callStatic() magic method".PHP_EOL;
}
}
class B extends A {
public function bar() {
A::foo();
}
public function foo() {
parent::foo();
}
}
(new B)->bar();
(new B)->foo();
From what I understand, the function barcalls the method fooin the class Astatically, but the method foocalls the method using an instance Athat is the parent element B, I expect this to give me:
I'm the __callStatic() magic method
I'm the __call() magic method
But apparently I get:
I'm the __call() magic method
I'm the __call() magic method
source
share