Find out in which file location a self-defined Function or Class is located
When maintaining a project, especially the non-framework writing method, it is often seen that the previous program does not know which file the Class/Function is defined in. Although it can be easily found with the IDE, if it is not tracked by the IDE, is there any way? Can you know where the definition is? In fact, through ReflectionFunction and ReflectionClass.
ReflectionFunction
Can read information about the specified method
$reflFunc = new ReflectionFunction('method name'); echo $reflFunc->getFileName() . ':' . $reflFunc->getStartLine();
ReflectionClass
Can read the relevant information of the specified category
$reflectionClass = new ReflectionClass('Form'); echo $reflectionClass->getFileName() . ':' . $reflectionClass->getStartLine();
0 Comments