3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo{ public static function Bar(&$num){ $num*=50; } } $functionname = "Foo::Bar"; $num = 3; echo 'call_user_func_array: '; call_user_func_array($functionname, &array($num)); echo $num; echo "\n"; $num = 3; echo "other way: "; if (stristr($functionname, '::') !== false) { list($class, $function) = explode('::', $functionname); $class::$function($num); } else { $functionname($num); } echo $num;
Output for 5.4.0 - 5.4.17
Parse error: syntax error, unexpected 'array' (T_ARRAY) in /in/3L3FD on line 11
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_ARRAY in /in/3L3FD on line 11
Process exited with code 255.

preferences:
178.46 ms | 1395 KiB | 53 Q