The main content of this article is about the method of php function not defining parameters, which has a certain reference value. Now I share it with everyone. Friends in need can refer to it
<?php function func() { $numargs = func_num_args();//数组返回 echo "参数个数: $numargs\n"; $args = func_get_args();//获得参数的数组 var_dump($args);//把数组打印出来 } myfun(1, '2'); echo '<br>'; myfun('aa', 3.4, 5, 6, 7); echo '<br>'; myfun(); ?>
Result:
78.5
113.04
Number of parameters: 2 array(2) { [0]=> int(1) [1]=> ; string(1) "2" }
Number of parameters: 5 array(5) { [0]=> string(2) "aa" [1]=> float(3.4 ) [2]=> int(5) [3]=> int(6) [4]=> int(7) }
Number of parameters: 0 array(0) { }
Related recommendations:
Detailed explanation of common methods of passing parameters in php
The above is the detailed content of php function does not define parameter method. For more information, please follow other related articles on the PHP Chinese website!