Rumah > Artikel > pembangunan bahagian belakang > 如何获得函数本身有多少个参数
怎么获得函数本身有多少个参数?
<?php <br /><br />function hello($param1,$param2,...){<br /> echo 'function name is:'. __FUNCTION__; // get function itself name<br /> // how to get how many parameters in these function ,<br /> echo '<br>has ? parameters';<br />}<br />hello();
<br />function hello(){<br /> echo 'function name is:'. __FUNCTION__; // get function itself name<br /> // how to get how many parameters in these function ,<br /> echo '<br>has '.func_num_args().' parameters<br>';<br /> $params = func_get_args();<br /> foreach($params as $param){<br /> echo $param.'<br>';<br /> }<br />}<br />hello(1,2,3);<br />