A function is a shortcut function for instantiating a controller in TP, which has the following syntax structure:
A (' Module/Controller ')// when the controller layer name is not controllers it is required to write A (' Module/controller ', ' Controller layer name ')
If the controller to be called is under the current module, it can also be written as follows:
A (' controller ')// or such a (' controller ', ' Controller layer name ')
Typically, an access controller is instantiated automatically, and the system is automatically instantiated based on the URL address of the controller that is accessed, and the associated action method is called. For example, we enter the following URL address:
http://Servername/home/index/index
The Indexcontroller class in home/controller/indexcontroller.class.php is now automatically instantiated. But if you need to call across a controller, you must instantiate it before calling:
Assuming that the home module is currently under the index controller
Instantiate the User controller for the Home module $Usernew \home\controller\usercontroller (); // Instantiate the Admin module's blog controller $Blog new \admin\controller\blogcontroller ();
The above code, if used with A function, can be simplified as follows:
$User // because the User controller is under the current module Home, the module name can be omitted $Blog = A (' Admin/blog ');
By default, the A method instantiates the default controller layer (controllers), and if you are instantiating other hierarchical controllers (such as Event), you can use:
// Suppose the current module is the Home module//instantiation Event Controller $User = A (' User ', ' event '$Blog = A (' Admin/blog ', ' event ');
The above code is equivalent to:
// instantiate the user event controller for the home module $User New \home\event\userevent (); // Instantiate the Admin module's Blog event controller $Blog new \admin\event\blogevent ();
A function in thinkphp (Thinkphp3.2.3 version)