PHP uses a reflection mechanism to find where classes and methods are located, where PHP is located
The example in this article describes how PHP uses the reflection mechanism to find the location of classes and methods. Share to everyone for your reference, as follows:
Parameter 1 is the class name, parameter 2 is the method name $func = new Reflectionmethod (' unifiedorder_pub ', ' Getprepayid ');//starting from the first line $start = $func Getstartline ()-1;//end from the first few lines $end = $func->getendline ()-1;//get path address $filename = $func->getfilename ();
The following is a complete sample code excerpt
<?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 when there is only one parameter as the release of this class, presumably, self-baidu $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 '));? >
Read more about PHP related content readers can view the topic: "Php+ajax Tips and Applications Summary", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "PHP Basic Grammar Primer Tutorial", "PHP operation Office Document Tips Summary ( including word,excel,access,ppt), PHP date and Time usage summary, PHP Primer for object-oriented programming, PHP string usage Summary, PHP+MYSQL database Operations Starter Tutorial, and A summary of common PHP database operation techniques
I hope this article is helpful to you in PHP programming.
http://www.bkjia.com/PHPjc/1122884.html www.bkjia.com true http://www.bkjia.com/PHPjc/1122884.html techarticle PHP uses a reflection mechanism to find where classes and methods are located, where PHP is located This example describes how PHP uses the reflection mechanism to find where classes and methods are located. Share for the big ...