3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function foo1() { echo __FUNCTION__, "\n"; } class Foo { function do_foo() { echo __METHOD__, "\n"; } static function static_foo() { echo __METHOD__, "\n"; } } $funs = array( 'foo1', 'Foo::static_foo', array(new Foo(), 'do_foo'), function () { echo __FUNCTION__, "\n"; }, ); foreach ($funs as $fun) { echo "direct call: "; $fun(); echo "call_user_func(): "; call_user_func($fun); }
Output for 7.0.0 - 7.1.0
direct call: foo1 call_user_func(): foo1 direct call: Foo::static_foo call_user_func(): Foo::static_foo direct call: Foo::do_foo call_user_func(): Foo::do_foo direct call: {closure} call_user_func(): {closure}
Output for 5.3.0 - 5.6.28
direct call: foo1 call_user_func(): foo1 direct call: Fatal error: Call to undefined function Foo::static_foo() in /in/91evT on line 20
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/91evT on line 15
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/91evT on line 15
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/91evT on line 7
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_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/91evT on line 7
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/91evT on line 7
Process exited with code 255.