用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2184|回复: 3
收起左侧

[HELP] URL问题

[复制链接]
发表于 2011-5-25 18:06:35 | 显示全部楼层 |阅读模式
index.php/blog/show/3这样的链接在控制器中接收参数时,什么都不处理就能得到3吗?按我的理解的话,应该是得先要id=$this->uri->segment(3),然后才能输出id为3吧,如果不做这一步,直接echo就能得到3吗?
发表于 2011-5-25 18:13:29 | 显示全部楼层
echo $this->uri->segment(3);
发表于 2011-5-25 23:10:03 | 显示全部楼层
function show($id=0){
    echo $id;
}
 楼主| 发表于 2011-5-26 10:40:39 | 显示全部楼层
是不是有两种方法可以得到参数的值,一种是用
function show($id=0){
    echo $id;
}
另一种是
function show(){
    echo $this->uri->segment(3);
}
这样理解对不对

本版积分规则