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/>';
}
精彩评论