Home >Backend Development >PHP Tutorial >How to find the source code of func_get_args()?
/**
<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>
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.
/**
<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>
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...