这是我的方法
public function sale($id,$type){
if($id==TRUE){
.....................
.....................
}
if($type==TRUE){
.......................
.......................
}
}
我想单独浏览两个参数,假设
和
怎么可能
答案 0 :(得分:1)
试试这个:
网址格式:http://mysite.com/mycontroller/sale/id(不可能)
现在:http://mysite.com/mycontroller/sale/selector/id/value/1
现在:http://mysite.com/mycontroller/sale/selector/type/value/1
function sale(){
$type = $this->uri->segment(4); #get the selector
$val = $this->uri->segment(6); #get the value
if( $type == "id" ){
#in id selection
}else if( $type == "type" ){
#in type selection
}else{
redirect('somewhere', 'refresh');
}
}
答案 1 :(得分:0)
您可以使用网址传递多参数:
例如关注网址:
http://mysite.com/mycontroller/sale
http://mysite.com/mycontroller/sale/3
http://mysite.com/mycontroller/sale/3/computer
此处代码:
public function sale($id = false, $type = false) {
if($id) {
// something to do
}
if($type) {
// something to do
}
}