The A method of ThinkPHP is used to instantiate the Controller internally. The call format is as follows:
A ('[Project: //] [group/] module', 'controller layer name ')
The simplest usage:
$ User = A ('user ');
The UserAction controller of the current project is instantiated (the file corresponding to this controller is located in Lib/Action/UserAction. class. php). If you use the grouping mode and want to instantiate the controller of another Admin group, you can use:
$ User = A ('admin/user ');
Cross-Project instantiation is also supported (the project directory must be at the same level)
$ User = A ('admin: // user ');
The UserAction Controller under the Admin project is instantiated.
The version 3.1 of ThinkPHP adds support for hierarchical controllers, so other controllers can be instantiated using the method, for example:
$ User = A ('user', 'event );
Instantiate the UserEvent controller (the corresponding file is in Lib/Event/UserEvent. class. php ).
After the controller is instantiated, you can call the methods in the Controller. However, when calling a controller across projects, if your operation method has special variable operations for the current controller, there will be some unknown issues, so in general, the official recommendation is to develop a public call controller layer separately, do not have too many dependencies.