buaa_hyz 发表于 2015-2-23 11:09:43

CI怎么取出URL中的变量

菜鸟请教大神,CI怎么取出URL中的变量

sqsx 发表于 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

為何不看手冊?

buaa_hyz 发表于 2015-2-23 11:11:39

补充:http://localhost /jp/index.php/student/toevaluate/course_id/1,怎么取出course

buaa_hyz 发表于 2015-2-23 11:12:39

补充:http://localhost/jp/index.php/student/toevaluate/course_id/1,怎么取出course_id这个值1,万分感谢!

Closer 发表于 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 來取得你的參數

 

Closer 发表于 2015-2-24 09:29:52

燃雲 发表于 2015-2-24 06:30
幽默!

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


我比較好奇,甚麼情況下才會用到那種功能
页: [1]
查看完整版本: CI怎么取出URL中的变量