getting function's argument names

后端 未结 6 971
清歌不尽
清歌不尽 2020-12-08 04:13

In PHP Consider this function:

function test($name, $age) {}

I need to somehow extract the parameter names (for generating custom documenta

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 04:51

    func_get_args

    function my($aaa, $bbb){
         var_dump(  func_get_args() );  
    }
    
    
    my("something","something");    //result:  array('aaa' => 'something', 'bbb' => 'something');
    

    also, there exists another global functions: get_defined_vars(), that returns not only function, but all variables.

提交回复
热议问题