thinkphp function: A method

Source: Internet
Author: User

The A method is used to instantiate the controller internally, calling the format:
A (' [Project://][Group/] module ', ' Controller layer name ')
The simplest usage:

  1. $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:

  1. $User = A(‘Admin/User‘);

复制代码

Cross-project instantiation is also supported (the catalog of the project is to remain sibling)

  1. $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:

  1. $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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.