In summary: Routing is the correspondence between the URL of the network request and the logical processing address of the thinkphp application layer.
#In layman’s terms: routing is to elegantly map the URL request to the operation method you want to perform.
How to understand? (Recommended learning: PHP programming from entry to proficiency)
Routing is actually to hide the real url address and use the access address to access the application (website or OA, etc.).
Usually defined like this: "Access address" = "Real address", which represents a mapping relationship.
Just like using "1" to represent eating at KFC, and using "0" to represent eating at McDonald's. If you have informed your colleagues of this rule in advance, you only need to send "1" or "0" to your colleagues, and they will It is a principle to understand where to go to eat.
The routing rules are specified by thinkphp. For example, the access rules of TP are: root directory/module/controller/method, then we only need to define the mapping relationship "reg" = "index/user/ reg". At this time, you only need to enter "domain name/reg" in the browser to access the address "index module/user/controller/reg method".
Such advantages:
1. Unprocessed url paths are composed of... modules/controllers/methods/parameters. If " If you cover it up, others will see the internal structure clearly, which is not safe enough.
2. It can make the URL address more concise, elegant and beautiful.
The above is the detailed content of What are the benefits of php routing. For more information, please follow other related articles on the PHP Chinese website!