我的下一个问题是:你如何将它们传递给另一个函数,比如function myFunc($params){anotherFunc($params);}但是 anotherFunc 会接收它们,就像使用 anotherFunc($p1, $p2, $p3, $p4, $p5...) 解决方案 call_user_func_array('anotherFunc', func_get_args());func_get_args 返回一个包含传递给调用它的函数的所有参数的数组,call_user_func_array 调用一个给定的函数,将参数数组传递给它.In php how would you create a function that could take an unlimited number of parameters: myFunc($p1, $p2, $p3, $p4, $p5...);My next question is: how would you pass them into another function something likefunction myFunc($params){ anotherFunc($params);}but the anotherFunc would receive them as if it was called using anotherFunc($p1, $p2, $p3, $p4, $p5...) 解决方案 call_user_func_array('anotherFunc', func_get_args());func_get_args returns an array containing all arguments passed to the function it was called from, and call_user_func_array calls a given function, passing it an array of arguments. 这篇关于PHP 函数的无限参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-12 13:15