Home > Article > Backend Development > How to get the parameter list of a class method in php
In php, the func_get_args() function can be used to obtain the parameter list of the class method. You only need to add the "$argsArr=func_get_args()" statement in the class method. The func_get_args() function can get all the parameters of the class method and return an array containing the parameter list.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, you can use the func_get_args() function to obtain The parameter list of the class method.
func_get_args() can get all parameters of a function or method and return an array containing a parameter list, where each element is a copy of the corresponding element of the parameter list of the current user-defined function.
<?php header("Content-type:text/html;charset=utf-8"); class Website { public function demo() { echo '成员方法 demo()'; $argsArr = func_get_args(); var_dump($numargs); } } $student = new Website(); $student -> demo(1,2); ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to get the parameter list of a class method in php. For more information, please follow other related articles on the PHP Chinese website!