In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about what route is used to do in thinkphp. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
In thinkphp, the function of route routing is to simplify the URL access address, and to make correct parsing according to the defined route type. The purpose of routing is to simplify the path and to define some rules while simplifying the path.
This article operating environment: Windows10 system, ThinkPHP5 version, Dell G3 computer.
What is the use of route routing in thinkphp
Network access addresses are always mapped, initially, hostname (computer name) = > ip address (such as LAN 192.168.1.1)
The routing definition is to hide the real url address and use the access address to access the application (website or OA or something). It is usually defined as: 'access address' = > 'real address', which represents a mapping relationship, such as "1" for going to your home and "0" for going to your co-worker. The rules for routing are determined by TP, for example, the access rules for TP are: root directory / module / controller / method. We just need to define the mapping, such as' reg'= > 'index/user/reg', so I just need to type "domain name / reg" in the browser to access the address "index module / user controller / reg method".
Because normal url paths that we have not dealt with are all. Module / controller / method / parameter composition, if not "covered", some people will see the internal structure clearly, I do not know what will be done; when there is a certain aesthetic aspect.
Match the URL request gracefully to the method of operation you want to perform. Thinkphp routing can make your URL address more concise and elegant.
What is 1.Route (routing)?
The function of the = > route defined in the official document is to simplify the URL access address and make the correct resolution according to the defined route type.
Manual explanation: usually when we visit our ThinkPHP project as usual, the regular url should be written like this, (local example) http://localhost/ project name / public/index.php/ module name / controller name / method name
After entering a string of url, I will feel desperate. (whisper complaint) > "I just want to test a small interface so that I can type such a long list of addresses, which is too long to remember." At this time, we can use routing to simplify his address and define some rules while shortening the address.
two。 Why use routing?
Someone may blurt out: to simplify the path. Of course, this is one of the reasons, but the reason is not that simple.
Simplifying the path is a big reason, because at first I thought the path was too long and ran to turn it on, but later in the process of using it, I found that the role of Route is not limited to simplifying the path.
We can turn on the mandatory use of routes so that everyone can only come in from the routes I define. This has an advantage. You write some scripts in some controllers that you do not want to access. If you enable full routing to force use, users cannot access these scripts. Otherwise, if users access these scripts, the scripts sometimes modify the database, then it will be more dangerous.
There is that we can define from this path is a get operation or post operation, there will not be any situation before, a controller method, you can also access from get, post can also access, it is very messy, of course, some people will say, get and post can access it is no big deal, in fact, to distinguish between these methods, for the embodiment of the idea of Restful API is more helpful.
These are all the contents of the article "what does route do in thinkphp?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.