3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Foo { private function thing() { var_dump('asdf'); } } class Bar extends Foo { private function thing() { parent::thing(); } public function getThing() { $this->thing(); } } class Baz extends Foo { private function thing() { var_dump('qwer'); } public function getThing() { $this->thing(); } } $bar = new Bar(); $bar->getThing(); $baz = new Baz(); $baz->getThing();
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to private method Foo::thing() from context 'Bar' in /in/SupfD:9 Stack trace: #0 /in/SupfD(12): Bar->thing() #1 /in/SupfD(25): Bar->getThing() #2 {main} thrown in /in/SupfD on line 9
Process exited with code 255.
Output for 5.3.28 - 5.3.29, 5.4.20 - 5.6.28
Fatal error: Call to private method Foo::thing() from context 'Bar' in /in/SupfD on line 9
Process exited with code 255.
Output for 5.0.0 - 5.3.27, 5.4.0 - 5.4.19
Fatal error: Call to private method Foo::thing() from context 'Bar' in /in/5kr2Q on line 9
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/5kr2Q on line 3
Process exited with code 255.
Output for 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/5kr2Q on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/5kr2Q on line 3
Process exited with code 255.
Output for 4.3.0
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/SupfD on line 3
Process exited with code 255.