When debugging open source code, you want to see the definition of a function, you need to locate its location. In an IDE like Zend Studio, you can automatically prompt, but what can we do when there is no such development tool installed? Refer to the following code, perhaps including what you need.
Copy Code code as follows:
<?php
function A () {
}
Class B {
Public function f () {
}
}
function Function_dump ($funcname) {
try {
if (Is_array ($funcname)) {
$func = new Reflectionmethod ($funcname [0], $funcname [1]);
$funcname = $funcname [1];
} else {
$func = new Reflectionfunction ($funcname);
}
catch (Reflectionexception $e) {
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 '));
?>