首页 > 其他 > 详细

CI中的router设置

时间:2015-04-18 13:10:42      阅读:209      评论:0      收藏:0      [点我收藏+]

CI中的router设置

application/config/routes.php中定义了一个名为$route的数组,用来设置默认路由和404页面以及可以设置一些匹配方式。

1.设置默认路由 $route[‘default_controller’] = “demo/index”; demo 对应controller 名称, index 对应方法名称

2.route[list]=demo/list;route[‘p/([0-9]+)?’] = “demo/details/1;访functiondetail(id = 0 ){} 给 $id 、

以此类推,可以写多种规则的路由,写个复杂的

route[(fenlei|tag)/(hot7|hot30|hotall)?/p([0?9]+)?]=demo/index/1/3//2″;

function index(articletype=fenlei,page = 1,tag=,hot_filter= ‘new’){}

$article_type 对应 fenlei|tag

$hot_filter 对应 hot_7|hot_30|hot_all

$page 对应 ([0-9]+)?

这样可以很好的将url中的参数传入函数中,这种方法比较简洁,另外还有一种方法可以获取url参数,使用($this->uri->segment_array();)这个函数获取各个参数但是比较乱。

CI中的router设置

原文:http://blog.csdn.net/biboqingtian/article/details/45111927

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!