Thinkphp entry 2 (46) and thinkphp entry 46. Thinkphp entry 2 (46), thinkphp entry 46 [empty operation processing] see the following figure: a user accesses an operation that does not exist. Solution: define _ empty () for each controller () thinkphp entry 2 (46) and thinkphp entry 46
[Empty operation processing]
See the following figure:
A user accesses an operation that does not exist. Solution: define the _ empty () method for each controller to process the operation.
Solution 2: define an empty operation
[Empty module processing]
We use a class, but this class is not included yet.
We can use the automatic loading mechanism to process _ autoload (). If this automatic loading mechanism does not find this class, an error is returned.
Request an empty module
Solution 1: define an empty controller and module
Solution 2:
[Add a function library file to the application]
In the Common folder, it is the place where we put the library file.
[Module group] 1. set the controller Group
2. View templates need to be grouped
3. configure variables to be grouped
4. configure config. php
[Pre-operation and post-operation]
When the methods in the controller are called, some additional work can be done before or after the call, which is called pre-operation and post-operation.
When we request this URL: http: // URL/index. php/Admin/Goods/zhanshi, where the action occurs when the method exists, App. class. in the exec () method of php
There are many methods in a class that require both pre-and post-Operations. how can this problem be solved?
Solution:
[Cross-module call]
Instantiate a non-existent class, which will be automatically loaded through the _ autoload () mechanism.
Where is the _ autoload () of the tp framework? In Think. class. php
Instantiate A controller object using the () method
A ('Module controller') example: A ('Goods ')
A ('group/controller') for example: A ('Home/ucenter ');
A ('Project: // group/controller') for example: A ('shop: // home/ucenter ');
The A () method contains nested calls to the import () method. this method helps us obtain the corresponding controller and introduces require. A () method directly new the instantiated object by the way
R ("Project: // group/controller/Operation") method
It inherits the introduction, instantiation, and method calls of controllers.
R ('Module controller/operation') 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 the () method in the R () method.
Call the import () method in the () method.
A () method usage
R () method usage
Step 2 (46), thinkphp entry 46 [empty operation processing] see the figure below: a user accesses an operation that does not exist. Solution: define _ empty () for each controller () method...