开发者

how to get variable names of a parent function/method?

debug_backtrace开发者_开发百科() is only returning args array with names populated only with numbers, so maybe there are other hacks to get to parent scope context ?


Check out Reflector Function

http://www.php.net/manual/en/class.reflectionfunction.php

Example

function test($test){
    return $test;
}


$method = new ReflectionFunction('test');
var_dump( $method->getParameters() ); 

foreach($params as $param){
    echo $param->name.'<br/>';
}

Class Example using ReflectionMethod

class MyClass{

function test($test,$world){
    return $test;
}
}

$method = new ReflectionMethod('MyClass','test');
$params = $method->getParameters();

foreach($params as $param){
    echo $param->name.'<br/>';
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜