[英]Codeigniter Router $this->uri->segment not working exactly
I have two-way access: 我有两种访问方式:
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
And my router 还有我的路由器
$route['([a-z\-]+)/tag/([a-z\-]+)/(:num)']='main/selectBaivietTag/$1/$2';
$route['([a-z\-]+)/tag/([a-z\-]+)']='main/selectBaivietTag/$1/$2';
I want access the second but $this->uri->segment(5)=2 not =1, Please help me! 我想访问第二个,但$ this-> uri-> segment(5)= 2不是= 1,请帮助我! Thanks alot!
非常感谢!
try use 尝试使用
for the first link 对于第一个链接
1 : http://website.com/main/selectBaivietTag/video/chon-loc/2
you can get your value with this 你可以以此来获得价值
$this->uri->segment(5)
this will give your value ie 2 but for second links 这将给你的价值,即2,但第二个链接
2 : http://website.com/video/tag/chon-loc/2
you can get your value with this 你可以以此来获得价值
$this->uri->segment(4)
this will give your value ie 2 这将给你的价值,即2
try use 尝试使用
$this->uri->rsegment(5); :))
https://www.codeigniter.com/user_guide/libraries/uri.html https://www.codeigniter.com/user_guide/libraries/uri.html
Try following code: 尝试以下代码:
<?php
$segment = $this->uri->segment_array();
echo $segment['5'];
?>
Working fine for me. 对我来说很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.