简体   繁体   中英

Pass-by-reference for functions with varying length of functions

I have a function with optional number of arguments, something like this:

function DoSomething()
{
    $args = funct_get_args();

    // and the rest of function
}

In the function above, how can I define the first argument to be passed by reference?

So when I calling it, I be able to do so:

DoSomething(&$first, $second, $third);

Simply declare it in the parameter list:

function DoSomething(&$first) {
    $args = func_get_args();
    // and the rest of function
}

DoSomething($first, $second, $third);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM