How to get the number of parameter with their name of a defined function

You can get the number of parameters with their name of a function.

PHP provides a class ReflectionFunction. It's a built-in class, so no
need to add any extra library.

<?php
function get_func_argNames($funcName) {
$f = new ReflectionFunction($funcName);
$result = array();
foreach ($f->getParameters() as $param) {
$result[] = $param->name;
}
return $result;
}

print_r(get_func_argNames('get_func_argNames'));

?>

Comments

Popular posts from this blog

cookie and subdomains

How to check browser cookie enabled with php and javascript