# JS Call function method for passing variable parameters
<script> function Test () {for (var i = 0;i < Arguments.length; i++) {alert (arguments[i]); }}//Call function Test (1, 2, 3, ' abc '); </script>
How PHP calls functions to pass mutable parameters
<?php//Method One//receive a series of parameters and output function Show_params () {//Get the number of pass parameters $count = Func_num_args (); Traverse parameters and output each for ($i = 0; $i < $count; $i + +) {//get parameter $param = Func_get_arg ($i); Echo $param. Php_eol; }}//Call function Show_params (1, 2, ' Apple ', 3.14); Method 2 function Show_params () {//defines an array of stored pass parameters $params = Array (); Get all parameters $params = Func_get_args (); $count = count ($params); Iterate and output parameters for ($i = 0; $i < $count; $i + +) {echo $params [$i]; Echo Php_eol; }}//Note: Method 2 performs slower than Method 1
Related articles:
How does PHP pass each element of an array as an argument to a mutable parameter function?
PHP variable parameters
PHP variable parameter implementation