php中,可用func_get_args()函数来获取类方法的参数列表,只需要在类方法内添加“$argsArr=func_get_args()”语句即可。func_get_args()函数可获取类方法的所有参数,返回一个包含参数列表的数组。
本教程操作环境:windows7系统、PHP7.1版、DELL G3电脑
php中,可用func_get_args()函数来获取类方法的参数列表。
func_get_args()可以获取函数或方法的所有参数,返回一个包含参数列表的数组,其中每个元素都是目前用户自定义函数的参数列表的相应元素的副本。
<?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);
?>