Home  >  Article  >  Backend Development  >  How to get the parameter list of a class method in php

How to get the parameter list of a class method in php

青灯夜游
青灯夜游Original
2022-02-15 13:35:582709browse

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.

How to get the parameter list of a class method in php

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 &#39;成员方法 demo()&#39;;
		$argsArr = func_get_args();
		var_dump($numargs);
	}

}

$student = new Website();
$student -> demo(1,2);
?>

How to get the parameter list of a class method in php

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!

Statement:
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