Home >Backend Development >PHP Problem >How to pass variable parameters in php?
php method to implement indefinite parameter passing: use the [func_num_args()] function to return the total number of parameters, the code is [ $args = func_get_args(); for($i=0;$i
php method to implement indefinite parameter passing:
If you want to pass an indefinite number of parameters, you need to use func_get_args()
Function to pass
func_num_args()
Function to return the total number of parameters
<?php function more_args(){ $args = func_get_args(); for($i=0;$i<func_num_args();$i++){ $a = $i +1; echo "第".$a."个参数是".$args[$i]."<br>"; } } more_args('a','b','c','d','e','f'); ?>
Execution results
Related learning recommendations: PHP programming from entry to proficiency
The above is the detailed content of How to pass variable parameters in php?. For more information, please follow other related articles on the PHP Chinese website!