3v4l.org

run code in 300+ 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.16, 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.

preferences:
172.99 ms | 1395 KiB | 29 Q