php - how to get variable names of a parent function/method? -
debug_backtrace()
returning args array names populated numbers, maybe there other hacks 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 $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 $param){ echo $param->name.'<br/>'; }
Comments
Post a Comment