When debugging open source code and want to see the definition of a certain function, you need to locate its location. It can be automatically prompted in IDEs like zend studio, but what can we do when such development tools are not installed? Refer to the following code snippet, which may contain what you need.
class b {
public function f() {
}
}
function function_dump($funcname) {
try {
if(is_array($funcname)) {
$func = new ReflectionMethod($funcname[0], $funcname[1]);
$funcname = $funcname[1];
> echo $ e->getMessage();
return;
}
$start = $func->getStartLine() - 1;
$end = $func->getEndLine() - 1 ;
$filename = $func->getFileName();
echo "function $funcname defined by $filename($start - $end)n";
}
function_dump('a' );
function_dump(array('b', 'f'));
$b = new b();
function_dump(array($b, 'f'));
? >
www.bkjia.com