thinkphp empty module and empty operation is also a useful function, the concept of empty module is when thinkphp can not find the specified module, it will attempt to locate the empty module (emptyaction), the empty module inside the index operation. Similarly, the empty operation is the same concept, when the system cannot find the operation method under the specified module, it will try to locate the empty operation method (empty). In fact, very good understanding, a bit like the PHP virtual host inside the custom 404 page, but it is more flexible than the custom 404, using this mechanism, we can implement the error page and some URL optimization, the following detailed description of the next empty module and empty operation.
1. Empty module , define the Emptyaction class in the project:
<?phppublic class Emptyaction extends Action {public Function index () {echo "current module does not exist"; }}? >
This is a simple empty module class, of course, you can also do some more complex operations, everything must be written according to the needs of the project, here is just a demonstration.
2. Empty operation, the empty operation is defined under the specified module, for example, we define an empty operation under the user module, which is the Useraction class.
<?phpclass Useraction extends Action{public function index () {$this->display (); } Public Function Demo () {$this->display (); } Public Function _empty () { //the method is empty operation Echo ' current operation does not exist '; }? >
The code is simple, and this is an empty method, and empty modules and empty operations can be used at the same time to accomplish more complex operations.
http://www.bkjia.com/PHPjc/824728.html www.bkjia.com true http://www.bkjia.com/PHPjc/824728.html techarticle thinkphp Empty module and empty operation is also a very useful function, the concept of empty module is when thinkphp can not find the specified module, it will try to locate the empty module (emptyaction), ...