In Python I can do this:
def f(a, b, c):
print a, b, c
f(*[1, 2, 3])
How do you say this in PHP?
Use call_user_func_array:
call_user_func_array('f', array(1, 2, 3));
If you wanted to call a class method, you'd use array($instance, 'f')
instead of 'f'
and if it was a static class function you'd use array('ClassName', 'f')
or 'ClassName::f'
. See the callback type docs for details about that.
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