Introduction to ThinkPHP routing mechanism, thinkphp routing mechanism_PHP tutorial

WBOY
Release: 2016-07-12 08:56:16
Original
1015 people have browsed it

Introduction to ThinkPHP routing mechanism, thinkphp routing mechanism

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('模块名称','操作名称','参数定义','额外参数'), 
 //常规路由
);

Copy after login

For example, we enable routing and define the following routing rule:

'blog'=>array('Blog','index','year,month,day','userId=1&status=1')

Copy after login

Then we are executing

Copy code The code is as follows:http:/ //appName/blog/2007/9/15

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.

Articles you may be interested in:

  • Detailed explanation of ThinkPHP routing
  • ThinkPHP, ZF2, Yaf, Laravel framework routing competition
  • thinkphp’s URL routing rules With configuration examples
  • Rewrite the U method of ThinkPHP to make paging under the route normal
  • Detailed explanation of thinkphp routing rules usage examples and pseudo-static function implementation (apache rewrite)
  • ThinkPHP MVC development mechanism example analysis
  • ThinkPHP uses Smarty third-party plug-in method summary
  • thinkphp implements image upload function
  • thinkPHP query method summary
  • thinkphp namespace usage Detailed explanation of examples
  • Example analysis of paging usage in thinkPHP

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1113706.htmlTechArticleIntroduction to ThinkPHP routing mechanism, thinkphp routing mechanism 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, you need to enable it...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template