开发者

PHP equivalent of Python's func(*[args])

In Python I can do this开发者_JAVA技巧:

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜