duanrong5927 2011-06-03 12:31
浏览 31

too long

What is the difference between these two code excerpts, respectively, in PHP?:

function eat_apple($apple)
{
    return true;
}

And:

function eat_apple()
{
    $apple = func_get_arg(0);
    return true;
}

Or is there a difference? If there is not, what is the point of func_get_arg()? Surely it serves some purpose I'm not aware of?

  • 写回答

5条回答 默认 最新

  • dongqing5575 2011-06-03 12:33
    关注

    func_get_arg (and func_get_args) make it possible to have functions with a variable number of parameters, so called variadic functions.

    Take array_merge as an example, which takes a variable number of arrays to be merged.

    评论

报告相同问题?