- Output for 7.1.25 - 7.1.27, 7.2.0 - 7.2.33, 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
- Hello World!
<?php
class A {
protected function test() {}
}
class B extends A {
public function test2($x) {
$x->test(); // Uncaught Error: Call to protected method D::test() from context 'B'
}
}
class C extends A {
protected function test() {}
}
class D extends C {
protected function test() {
echo "Hello World!\n";
}
}
(new B)->test2(new D);