Get number of parameters a function requires

前端 未结 2 1433
误落风尘
误落风尘 2020-12-10 15:03

This is an extension question of PHP pass in $this to function outside class

And I believe this is what I\'m looking for but it\'s in python not php: Programmaticall

2条回答
  •  一向
    一向 (楼主)
    2020-12-10 15:33

    Use Reflection, especially ReflectionFunction in your case.

    $fct = new ReflectionFunction('client_func');
    echo $fct->getNumberOfRequiredParameters();
    

    As far as I can see you will find getParameters() useful too

提交回复
热议问题