Is there a way to call a function using call_user_func and pass it parameters? For instance I have
function test($args)
{
echo "I DID IT!";
}
however I cannot call this function because it has a paramter which is not being passed by
call_user_func("test");
is there a way to call the function and provide parameters to it? (for instance, the ability to pass in a list arguments)? Any help is greatly appreciated!
If you were to read the documentation you would see that call_user_func()
accepts a variable number of arguments:
call_user_func('test', 'argument1', 'argument2');
You can also use call_user_func_array('callback', array('array','of','arguments'))
.
Use call_user_func_array, you can supply a list of parameters as array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With