Home >Backend Development >PHP Tutorial >How to define a function with variable number of parameters in PHP
This article mainly introduces the phpdefine the function usage with variable number of parameters. It analyzes the usage skills of func_get_args with examples. It has certain reference value. Friends who need it can refer to it. Next
The example in this article describes the usage of functions with variable number of parameters defined in PHP. Share it with everyone for your reference. The specific analysis is as follows: The
function parameters in<?php function addanything (){ $total = 0; $args = func_get_args (); for ($i = 0; $i < count ($args); $i++){ if (is_int ($args[$i])){ $total += $args[$i]; } } return $total; } echo addanything (1,5,7,8,11) . "<br />"; ?>
The above is the detailed content of How to define a function with variable number of parameters in PHP. For more information, please follow other related articles on the PHP Chinese website!