PHP equivalent of Python function (* [args])

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?

+4
source share
1 answer

Use call_user_func_array :

 call_user_func_array('f', array(1, 2, 3)); 

If you want to call a class method, you must use array($instance, 'f') instead of 'f' , and if it were a static class function, you would use array('ClassName', 'f') or 'ClassName::f' . You can learn more about this in the callback methods .

+9
source

All Articles