class A
{
private function foo() {
echo "A class success!\n";
}
public function test() {
echo get_class($this) . PHP_EOL; // C class here
var_dump($this) . PHP_EOL; // $this is object of C class here
$this->foo(); // but calling A class method foo here while we have our own foo in C. Why?
}
}
class C extends A
{
private function foo() {
echo "C class success!";
}
}
$c = new C();
$c->test();
Output
C
object(C)#1 (0) {
}
A class success!
We override private method foo in C class, but still calling A's foo. Why? $this - is value of the calling object. So we cant override private methods or what am i loosing?