如果要传递不定数量的参数,需要使用func_get_args()函数来传递

func_num_args()函数用来返回参数的总数

<?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');
?>

 执行结果

PHP函数(二)-不定参数的传递

 

相关文章:

  • 2021-12-15
  • 2019-09-12
  • 2022-12-23
  • 2021-08-06
  • 2022-02-07
  • 2021-05-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
  • 2021-06-21
  • 2022-12-23
相关资源
相似解决方案