3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Foo { private function privateMethod () { echo 'test'; } public function test () { Bar::run($this); } } class Bar { static public function run (\Foo $foo) { $foo->privateMethod(); } } $foo = new Foo; $foo->test();
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to private method Foo::privateMethod() from context 'Bar' in /in/0tUXF:12 Stack trace: #0 /in/0tUXF(6): Bar::run(Object(Foo)) #1 /in/0tUXF(17): Foo->test() #2 {main} thrown in /in/0tUXF on line 12
Process exited with code 255.
Output for 5.3.0 - 5.6.25
Fatal error: Call to private method Foo::privateMethod() from context 'Bar' in /in/0tUXF on line 12
Process exited with code 255.
Output for 5.0.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/0tUXF on line 11 Fatal error: Call to private method Foo::privateMethod() from context 'Bar' in /in/0tUXF on line 12
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/0tUXF on line 3
Process exited with code 255.
Output for 4.3.0 - 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/0tUXF 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/0tUXF on line 3
Process exited with code 255.