Home > Backend Development > PHP Tutorial > php function does not define parameter method

php function does not define parameter method

不言
Release: 2023-03-24 06:24:01
Original
1961 people have browsed it

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, &#39;2&#39;);
	 echo &#39;<br>&#39;;
	 myfun(&#39;aa&#39;, 3.4, 5, 6, 7);
	 echo &#39;<br>&#39;;
	 myfun();
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template