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', // function array(new Foo(), 'do_foo'), // object method array('Foo', 'static_foo'), // static class method function () { echo __FUNCTION__, "\n"; }, // anonymous function ); echo "call_user_func():\n"; foreach ($funs as $fun) { echo "\t"; call_user_func($fun); } echo "\ndirect call():\n"; foreach ($funs as $fun) { echo "\t"; $fun(); }
Output for 5.4.0 - 7.1.0
call_user_func(): foo1 Foo::do_foo Foo::static_foo {closure} direct call(): foo1 Foo::do_foo Foo::static_foo {closure}
Output for 5.3.0 - 5.3.29
call_user_func(): foo1 Foo::do_foo Foo::static_foo {closure} direct call(): foo1 Fatal error: Function name must be a string in /in/DuL2X on line 26
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/DuL2X 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/DuL2X 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/DuL2X 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/DuL2X 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/DuL2X on line 7
Process exited with code 255.