How to create a global controller in thinkphp3.2 or a later version so that multiple modules can be used together! How to create a global controller in thinkphp3.2 or a later version so that multiple modules can be used together!
Reply content:
How to create a global controller in thinkphp3.2 or a later version so that multiple modules can be used together!
In fact, it is very simple to create a Controller under the Application/Common/Controller directory to inherit the Controller. The namespace is Common/Controller. The default directory does not exist. You need to manually create
Create a controller
Then other controllers extends will not be generic.
MyAction extends ActionOtherAction extends MyAction
TP3.2 already has a completely face-to-face object. We should use the face-to-face object solution, their inheritance relationship is that the Controller of the public method inherits the custom public Controller> inherits the Controller of the TP.
First, create CommonController. class. php under Home/Controller/to copy the namespace and use of this controller from any Controller.
Then modify it in the control that you need to use the method in this controller (for example, there is HelloController. class. php)
Class HelloController extends Controller {
Public function say (){
Echo "hello ";
}
}
Change
Class HelloController extends CommonController {
Public function test (){
Say ();
}
}
This is OK. Please try it on your phone ...... No typographical layout