This article mainly introduces the method of thinkphp3.2 to realize cross-controller calling other modules, and analyzes the common operating techniques of thinkPHP cross-module and cross-controller calling methods. Friends in need can refer to it
The example in this article describes how thinkphp3.2 implements cross-controller calls to other modules. Share it with everyone for your reference, the details are as follows:
Thinphp has methods for calling each other in the front and backend, which can save duplicate content.
1 2 |
|
The same goes for calling methods in other places.
The module name can be omitted if it is in the same controller.
For example, calling a method of a certain class in common:
1 2 |
|
The framework provides cross-module and controller-based A() Method
1 2 3 4 5 6 7 |
|
Calling demonstration:
1 2 3 |
|
If it is still not convenient enough, the framework also provides The R() method is used to instantiate the class and call the method.
1 2 3 4 |
|
The effect is as follows:
1 2 3 4 5 6 |
|
Related recommendations:
Detailed explanation of ThinkPHP’s method of realizing site staticization
thinkPHP’s method of realizing multi-field fuzzy matching query
The above is the detailed content of thinkphp3.2 realizes the method of calling other modules across controllers. For more information, please follow other related articles on the PHP Chinese website!