3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { public function myEcho($property) { echo $this->{$property} . PHP_EOL; } } class B extends A { private $private; protected $protected; public function set($property, $value) { $this->{$property} = $value; } } $b = new B(); $b->set('protected', 'test protected'); $b->myEcho('protected'); $b->set('private', 'test private'); $b->myEcho('private');
based on elofK
Output for 7.0.0 - 7.2.0
test protected Fatal error: Uncaught Error: Cannot access private property B::$private in /in/XoSoI:8 Stack trace: #0 /in/XoSoI(29): A->myEcho('private') #1 {main} thrown in /in/XoSoI on line 8
Process exited with code 255.
Output for 5.3.18 - 5.6.28
test protected Fatal error: Cannot access private property B::$private in /in/XoSoI on line 8
Process exited with code 255.