This article describes the ThinkPHP routing mechanism with examples. Share it with everyone for your reference, the details are as follows:
ThinkPHP supports URL routing function. To enable routing function, you need to set the ROUTER_ON parameter to true. After the routing function is turned on, the system will automatically detect the route. If a route name matching the current URL is found in the route definition, route parsing and redirection will be performed. The routing function needs to define a routing definition file, which is located under the configuration directory of the project. The file name is routes.php
Definition format:
Return Array( 'RouteName'=>array('模块名称','操作名称','参数定义','额外参数'), //常规路由 );
For example, we enable routing and define the following routing rule:
'blog'=>array('Blog','index','year,month,day','userId=1&status=1')
Then we are executing
Copy code The code is as follows:http:/ /
will actually execute the index operation of the Blog module. The subsequent parameters /2007/9/15/ will be parsed according to year/month/day in turn, and userId=1 and status=1 will be passed in implicitly. Two parameters.
Readers who are interested in more thinkPHP-related content can check out the special topics on this site: "ThinkPHP Getting Started Tutorial", "ThinkPHP Common Methods Summary", "Smarty Template Basic Tutorial" and "PHP Template Technology Summary".
I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.