Home > Backend Development > PHP Tutorial > How to find the source code of func_get_args()?

How to find the source code of func_get_args()?

WBOY
Release: 2016-08-18 09:16:25
Original
907 people have browsed it

/**

<code> *计算任意多个数的和,并返回计算后的结果
 */
function sum(){  //这里的括号中没有定义任何参数
    $total = 0;
    //使用func_get_args()来获取当前函数的所有实际传递参数,返回值为array类型
    $varArray = func_get_args();
    foreach ($varArray as $var){
        $total += $var;
    }
    return $total;
}

/*****下面是调用示例*****/
echo sum(1, 3, 5);  //计算1+3+5
echo sum(1, 2); //计算1+2
echo sum(1, 2, 3, 4);   //计算1+2+3+4
</code>
Copy after login
Copy after login

func_get_args() to get all the actual passed parameters of the current function, the return value is array type
How can I find the source code of func_get_args()? I'd like to see how to implement this behavior.

Reply content:

/**

<code> *计算任意多个数的和,并返回计算后的结果
 */
function sum(){  //这里的括号中没有定义任何参数
    $total = 0;
    //使用func_get_args()来获取当前函数的所有实际传递参数,返回值为array类型
    $varArray = func_get_args();
    foreach ($varArray as $var){
        $total += $var;
    }
    return $total;
}

/*****下面是调用示例*****/
echo sum(1, 3, 5);  //计算1+3+5
echo sum(1, 2); //计算1+2
echo sum(1, 2, 3, 4);   //计算1+2+3+4
</code>
Copy after login
Copy after login

func_get_args() to get all the actual passed parameters of the current function, the return value is array type
How can I find the source code of func_get_args()? I'd like to see how to implement this behavior.

The built-in function source code is available at https://github.com/php/php-sr...

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template