3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public static function bar() { $args = func_get_args(); var_dump($args); } } $method = array('Foo', 'bar'); $args = 123; call_user_func($method, $args); // NOT WORKING it just don't goes in the methods call call_user_func($method, 123); // NOT WORKING it just don't goes in the methods call call_user_func($method, (int) 123); // WORKING !! $method = array('Foo', 'bar'); $args = array(123, 456); call_user_func_array($method, $args); // NOT WORKING call_user_func_array($method, (array) $args); // NOT WORKING it just don't goes in the methods call call_user_func_array($method, array((array) $args)); // WORKING !!

preferences:
35.15 ms | 402 KiB | 5 Q