The A method is used to instantiate the controller internally, calling the format:
A (' [Project://][Group/] module ', ' Controller layer name ')
The simplest usage:
- $User = A(‘User‘);
复制代码
Represents the Useraction controller that instantiates the current project (the file that corresponds to this controller is located in lib/action/useraction.class.php), if the grouping mode is used, and the controller to instantiate another admin group can be used:
- $User = A(‘Admin/User‘);
复制代码
Cross-project instantiation is also supported (the catalog of the project is to remain sibling)
- $User = A(‘Admin://User‘);
复制代码
Represents the Useraction controller under the instantiation Admin Project
Version 3.1 adds support for layered controllers, so you can also instantiate other controllers with the A method, for example:
- $User = A(‘User‘,‘Event);
复制代码
Instantiate the Userevent controller (the corresponding file is located in lib/event/userevent.class.php).
After instantiating the controller, you can call the methods in the controller, but it is important to note that, in the case of cross-project invocation, if your action method has a special variable operation for the current controller, there will be some unknown issues, so, in general, the official recommendation requires a public call of the controller layer developed separately, Don't have too many dependencies.
thinkphp function: A method