ThinkPHP’s A method is used to instantiate the controller internally, and its calling format is:
A('[project://][group/]module','controller layer name')
Easiest usage:
$User = A('User');
means instantiating the UserAction controller of the current project (the file corresponding to this controller is located in Lib/Action/UserAction.class.php). If the grouping mode is adopted and you want to instantiate another Admin grouped controller, you can use :
$User = A('Admin/User');
Cross-project instantiation is also supported (project directories must remain at the same level)
$User = A('Admin://User');
represents instantiating the UserAction controller under the Admin project
ThinkPHP version 3.1 adds support for hierarchical controllers, so you can also use the A method to instantiate other controllers , for example:
$User = A('User','Event);
Instantiate the UserEvent controller (the corresponding file is located in Lib/Event/UserEvent.class.php).
After instantiating a controller, you can call methods in the controller. However, it should be noted that when calling across projects, if your operation method has special variable operations for the current controller, there will be some unknowns. Therefore, generally speaking, officials recommend that the controller layer that requires public calls be developed separately without too many dependencies.