3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // An example callback function function my_callback_function() { echo 'hello world!'; } // An example callback method class MyClass { static function myCallbackMethod() { echo 'Hello World!'; } } // Type 1: Simple callback call_user_func('my_callback_function'); // Type 2: Static class method call call_user_func(array('MyClass', 'myCallbackMethod')); // Type 3: Object method call $obj = new MyClass(); call_user_func(array($obj, 'myCallbackMethod')); // Type 4: Static class method call (As of PHP 5.2.3) call_user_func('MyClass::myCallbackMethod'); // Type 5: Relative static class method call (As of PHP 5.3.0) class A { public static function who() { echo "A\n"; } } class B extends A { public static function who() { echo "B\n"; } } call_user_func(array('B', 'parent::who')); // A ?>
Output for 5.3.0 - 7.1.0
hello world!Hello World!Hello World!Hello World!A
Output for 5.2.2 - 5.2.17
hello world!Hello World!Hello World!Hello World! Warning: call_user_func(B::parent::who): First argument is expected to be a valid callback in /in/aI0bO on line 41
Output for 5.1.0 - 5.2.1
hello world!Hello World!Hello World! Warning: call_user_func(MyClass::myCallbackMethod): Unable to call MyClass::myCallbackMethod() in /in/aI0bO on line 26 Warning: call_user_func(B::parent::who): First argument is expected to be a valid callback in /in/aI0bO on line 41
Output for 5.0.0 - 5.0.5
hello world!Hello World!Hello World! Warning: call_user_func(MyClass::myCallbackMethod): First argument is expected to be a valid callback in /in/aI0bO on line 26 Warning: call_user_func(B::parent::who): First argument is expected to be a valid callback in /in/aI0bO on line 41
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/aI0bO on line 10
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/aI0bO on line 10
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/aI0bO on line 10
Process exited with code 255.