# JS method of calling functions to pass variable parameters
Copy code The code is as follows:
<script> <br>function test() { <br> for(var i = 0;i < arguments.length; i++ ) { <BR> alert(arguments[i]); <BR> } <BR>} <BR>//Call function <BR>test(1, 2, 3, 'abc'); <BR></script>
Copy codeThe code is as follows:
//Method 1
//Receive a series of parameters and output them one by one
function show_params () {
// Get the passed parameters Number
$count = func_num_args();
//Traverse the parameters and output them one by one
for ($i = 0; $i < $count; $i++) {
//Get the parameters
$param = func_get_arg($i ); C Echo $ Param. PHP_EOL;
}}}
// Call the function
show_params (1, 2, 'apple', 3.14); Array of
$params = array();
//Get all parameters
$params = func_get_args();
$count = count($params); $i < $count; $i++) {
echo $params[$i];
echo PHP_EOL;
}
}
//Note: Method 2 executes slower than method 1
The above has introduced the qq space background music player code and the difference between JS and PHP in passing variable parameters to functions. The example code includes the content of the qq space background music player code. I hope it will be helpful to friends who are interested in PHP tutorials.