ThinkPHP empty module and empty operation details. ThinkPHP's empty module and empty operation are also very useful functions. The concept of empty module is that when ThinkPHP cannot find the specified module, it will try to locate the empty module (EmptyAction ), thinkPHP's empty module and empty operation are also very useful functions. The concept of empty module is that when ThinkPHP cannot find the specified module, it will try to locate the empty module (EmptyAction ), perform the index operation in the empty module. Similarly, empty operations are 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, it is a bit similar to the custom 404 page in the php virtual host, but it is more flexible than the custom 404, using this mechanism, we can optimize the error page and some URLs. The following describes the empty module and empty operation methods in detail.
1. empty module, Define the EmptyAction class in the project:
<? Phppublic class EmptyAction extends Action {public function index () {echo "the current module does not exist" ;}}?>
This is a simple empty module class. of course, you can also perform more complex operations in it. everything has to be written according to the project requirements. here is just a demonstration.
2. empty operationAn empty operation is defined under the specified module. for example, we define an empty operation under the User module and the UserAction class.
<? Phpclass UserAction extends Action {public function index () {$ this-> display ();} public function demo () {$ this-> display ();} public function _ empty () {// This method is null Operation echo 'current operation does not exist'; }}?>
The code is very simple. this is an empty method, and empty modules and empty operations can be used at the same time to complete more complex operations.
Values (EmptyAction ),...