[英]Codeigniter Router $this->uri->segment not working exactly
我有两种访问方式:
1 : http://website.com/main/selectBaivietTag/video/chon-loc/2 //$this->uri->segment(5)=2
2 : http://website.com/video/tag/chon-loc/2 //$this->uri->segment(5)=1
还有我的路由器
$route['([a-z\-]+)/tag/([a-z\-]+)/(:num)']='main/selectBaivietTag/$1/$2';
$route['([a-z\-]+)/tag/([a-z\-]+)']='main/selectBaivietTag/$1/$2';
我想访问第二个,但$ this-> uri-> segment(5)= 2不是= 1,请帮助我! 非常感谢!
尝试使用
对于第一个链接
1 : http://website.com/main/selectBaivietTag/video/chon-loc/2
你可以以此来获得价值
$this->uri->segment(5)
这将给你的价值,即2,但第二个链接
2 : http://website.com/video/tag/chon-loc/2
你可以以此来获得价值
$this->uri->segment(4)
这将给你的价值,即2
尝试以下代码:
<?php
$segment = $this->uri->segment_array();
echo $segment['5'];
?>
对我来说很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.