P粉1976397532023-08-17 16:50:14
Latest versions of PHP do not allow a mismatch between the function parameter list and the parameter list in the call. You can use ellipses in the argument list to allow unlimited arguments instead of calling func_get_args()
.
function calculate(...$args){ echo "参数个数:" . count($args) ; echo "第3个参数是:" . $args[3]; print_r($args); $result = 0; foreach($args as $arg) : $result += $arg; end foreach; echo $result; }