PHP uses the reflection mechanism to locate the class and method, and php. PHP uses the reflection mechanism to find the location of classes and methods. This article describes the location where php uses the reflection mechanism to find classes and methods. I would like to share with you the location where PHP and php are located by using the reflection mechanism to find classes and methods.
This example describes the location of the search class and method using the reflection mechanism in PHP. We will share this with you for your reference. The details are as follows:
// Parameter 1 is the class name, and parameter 2 is the method name $ func = new ReflectionMethod ('unifiedorder _ pub', 'getprepayid '); // start from the nth row $ start = $ func-> getStartLine ()-1; // end from the nth row $ end = $ func-> getEndLine ()-1; // Obtain the path $ filename = $ func-> getFileName ();
The sample code for excerpt is comprehensive.
<? Phpfunction 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 {// This should be considered as the release of this class when there is only one parameter, probably Baidu $ func = new ReflectionFunction ($ funcname );}} catch (ReflectionException $ e) {echo $ e-> getMessage (); return;} $ start = $ func-> getStartLine ()-1; $ en D = $ 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');?>