4

我想包装一个接受无限数量参数的现有函数,例如这是现有函数:

function T()
{
    $args = func_num_args();
    // Do stuff with arguments.
}

我现在想包装它,例如

/*
 * This function shall also take unlimited arguments,
 * and just pass them on to T().
 */
function myT()
{
    // TODO: Take all arguments and pass them on to T().
    $result = T();

    // Do stuff with the result of T().
}

但是,我无法弄清楚如何将无限参数传递给T()in myT()

4

1 回答 1

8

使用call_user_func_array()http://php.net/call_user_func_array

$res = call_user_func_array("T", func_get_args());
于 2013-10-10T16:13:23.747 回答