Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wrap function that takes unlimited number of arguments [duplicate]

I want to wrap an existing function that takes unlimited number of arguments, e.g. this is the existing function:

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

I now want to wrap it, e.g.

/*
 * 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().
}

However, I cannot figure out how to pass the unlimited arguments on to T() in myT().

like image 857
JohnSmith Avatar asked Feb 16 '23 00:02

JohnSmith


1 Answers

use call_user_func_array() (http://php.net/call_user_func_array)

$res = call_user_func_array("T", func_get_args());
like image 108
bwoebi Avatar answered Apr 26 '23 11:04

bwoebi