"Empty Operation Processing"
Look at the following diagram:
Actual situation: Our user controller does not have the Hello () method
An object to access a method that does not exist in this class, then it accesses the "Magic Method __call ()"
User accesses a non-existent action-"FIX: Define a _empty () method for each controller to handle
Second workaround: Define an empty operation
"Empty module Handling"
We use a class, but now this class is not included in the include.
We can handle __autoload () through the automatic loading mechanism, and if the automatic loading mechanism does not find this class, it will error.
That is, request an empty module
Resolution one: Define an empty controller, empty module
Workaround Two:
"Add library files to your app"
Inside the common folder is where we put our function library files.
"Module grouping" 1.group settings for the controller
2.view templates need to be grouped
3.configuration variables need to be grouped
4.do configuration config.php
"Pre-action, post-operation"
The method inside the controller can do some extra work before or after the call, and it is called the pre-operation, the post-operation.
When we request this URL:/http//URL/index.php/admin/goods/zhanshi, in the case where the method exists, where this action occurs, App.class.php's exec () method inside
The inside of the pre-operation, can be executed in Zhanshi (), the first execution
The back operation inside can be executed after Zhanshi ()
There are many methods inside a class that require both pre-and post-operation, and how should they be resolved?
Solve:
"Cross-module invocation"
Instantiating a nonexistent class will pass the __autoload () automatic loading mechanism.
Where is the __autoload () of the TP frame? In Think.class.php
Instantiating a controller object with a () method
A (' Module controller ') For example: A (' Goods ')
A (' Group/Controller ') For example: A (' home/ucenter ');
A (' Project://Group/controller ') For example: A (' shop://home/ucenter ');
There is a nested call to the import () method inside the A () method, which helps us to obtain the corresponding controller and introduce it require. A () method to instantiate an object by way of A Direct new
R ("Project://Group/Controller/operation") method
Is the introduction of the controller, the instantiation of the object, the invocation of the method to inherit well.
R (' Module controller/operation ') For example: A (' Goods ')
R (' Group/Controller/operation ') For example: A (' home/ucenter/members ');
R (' Project:///group/Controller/operation ') For example: A (' shop://home/ucenter/members ');
Call a () method inside the R () method
Call the import () method inside the A () method
The A () method uses
The R () method uses
thinkphp Introduction II (46)