- Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
- B's bar
<?php
abstract class A {
public function foo() {
// $this refers to $b/B regardless of the fact that the code is in A::foo
$this->bar();
}
public function bar() {
echo "A's bar";
}
}
class B extends A {
public function foo() {
parent::foo();
}
public function bar() {
echo "B's bar";
}
}
$b = new B();
$b->foo();