Joh*_*ith 4 php argument-passing
我想包装一个带有无限数量参数的现有函数,例如这是现有的函数:
function T()
{
$args = func_num_args();
// Do stuff with arguments.
}
Run Code Online (Sandbox Code Playgroud)
我现在想把它包起来,例如
/*
* 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().
}
Run Code Online (Sandbox Code Playgroud)
但是,我想不出如何通过无限的参数上T()在myT().
使用call_user_func_array()(http://php.net/call_user_func_array)
$res = call_user_func_array("T", func_get_args());
Run Code Online (Sandbox Code Playgroud)