PHP, how to pass func-get-args values to another function as list of arguments?

后端 未结 3 494
予麋鹿
予麋鹿 2020-12-29 20:38

I want to create a function (my_function()) getting unlimited number of arguments and passing it into another function (call_another_function()). <

3条回答
  •  梦谈多话
    2020-12-29 21:43

    Try call_user_func_array:

    function my_function() {    
        $args = func_get_args();
        call_user_func_array("another_function", $args);
    }
    

    In programming and computer science, this is called an apply function.

提交回复
热议问题