for example I need some code like:
if(need_params('function_name')):
print 'function_name($params)';
else
print 'function_name()';
endif;
You should have a look into the ReflectionFunction Class.
<?php
function need_params($func) {
$reflection = new ReflectionFunction($func);
return $reflection->getNumberOfParameters();
}
// use
function foo($arg) {}
echo need_params('foo') > 0 ? 'Needs params' : 'No params';
?>
You can get the number of function arguments through getNumberOfParamers().
You can check whetther the result is > 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With