3v4l.org

run code in 500+ PHP versions simultaneously
<?php class B { protected $x = 'x'; function foo() { return $this->x; } } class C extends B { private $x = 'y'; function foo() { return $this->x . parent::foo(); } } $c = new C; var_export($c->foo());
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.4
Fatal error: Access level to C::$x must be protected (as in class B) or weaker in /in/L11de on line 15
Process exited with code 255.
Output for 8.3.5
Fatal error: Access level to C::$x must be protected (as in class B) or weaker in /in/L11de on line 10
Process exited with code 255.

preferences:
35.04 ms | 1139 KiB | 7 Q