This article mainly introduces the thinkphp controller scheduling use examples, need friends can refer to the following
1. How to get the module name and controller name through the address bar parameter (even if there is a routing and rewriting module in the case) 2.TP is how to implement the predecessor, the Post method function module, and how to carry out the method with parameters? PHP system with the Reflectionclass,reflectionmethod class, you can reflect the user-defined classes in the attribute, the method of the permissions and parameters of information, such information can be accurately control the implementation of the method Reflectionclass Main methods: Hasmethod (string) existence of a method GetMethod (string) Fetch method Reflectionmethod Main methods: Getnumberofparameters () Get the number of parameters Getparamters () Get parameter information 3. Code demo code is as follows: <?php& nbsp Class indexaction{ public function Index () { echo ' index '. " RN "; &NBSP} public function Test ($year =2012, $month =2, $day =21) { echo $year. '--------'. $ month. '-----------'. $day. " RN "; &NBSP} public function _before_index () { echo __function__. " RN "; &NBSP} public function _after_index () { echo __function__. " RN "; &NBSP} //execute index method $method = new Reflectionmethod (' indexaction ', ' Index '); Permission to judge if ($method->ispublic ()) { $class = new Reflectionclass (' indexaction '); //Executes the predecessor Method if ($class->hasmethod (' _before_index ')) { $beforeMethod = $class->getmethod (' _before_index ' ); if ($beforeMethod->ispublic ()) { $beforeMethod->invoke (new indexaction); } } $method->invoke (new indexaction); //Execution if ($class->hasmethod (' _after_index ')) { $beforeMethod = $class->getmethod (' _ After_index '); if ($beforeMethod->ispublic ()) { $beforeMethod->invoke (new indexaction); } } & nbsp //execute a method with parameters $method = new Reflectionmethod (' indexaction ', ' test '); $params = $method->getparameters (); foreach ($params as $param) { $paramName = $param->getname (); if (Isset ($_request[$paramName)) $ args[] = $_request[$paramName]; elseif ($param->isdefaultvalueavailable ()) $args [] = $param->getdefaultvalue (); The If (count ($args) = = $method->getnumberofparameters ()) $method->invokeargs (new indexaction, $args); else echo ' parameters is not match! ';