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

[已解决] CI怎么取出URL中的变量

[复制链接]
发表于 2015-2-23 11:09:43 | 显示全部楼层 |阅读模式
菜鸟请教大神,CI怎么取出URL中的变量
发表于 2015-3-3 14:02:51 | 显示全部楼层
$this->uri->segment(4)
发表于 2015-2-24 06:30:41 | 显示全部楼层
Closer 发表于 2015-2-23 22:39
路徑 : http://localhost/jp/index.php/student/toevaluate/1

控制器 : student

幽默!

請參考CodeIgniter手冊中的URI 類的$this->uri->uri_to_assoc(n)例子。

http://codeigniter.org.cn/user_guide/libraries/uri.html

為何不看手冊?

点评

同意: 4.0
同意: 4
  发表于 2015-2-25 09:48
 楼主| 发表于 2015-2-23 11:11:39 | 显示全部楼层
补充:http://localhost /jp/index.php/student/toevaluate/course_id/1,怎么取出course
 楼主| 发表于 2015-2-23 11:12:39 | 显示全部楼层
补充:http://localhost/jp/index.php/student/toevaluate/course_id/1,怎么取出course_id这个值1,万分感谢!
发表于 2015-2-23 22:39:29 | 显示全部楼层
buaa_hyz 发表于 2015-2-23 11:12
补充:http://localhost/jp/index.php/student/toevaluate/course_id/1,怎么取出course_id这个值1,万分感 ...

路徑 : http://localhost/jp/index.php/student/toevaluate/1

控制器 : student
方法 : toevaluate
參數 : 1

請在方法 () 內加入自定義變數名稱
例如 ($course_id = 0) //預設為 0

然後在該方法內使用 $course_id 來取得你的參數

 
发表于 2015-2-24 09:29:52 | 显示全部楼层
燃雲 发表于 2015-2-24 06:30
幽默!

請參考CodeIgniter手冊中的URI 類的$this->uri->uri_to_assoc(n)例子。

我比較好奇,甚麼情況下才會用到那種功能

本版积分规则