Codeigniter将“名称/名称”作为URL中的一个参数传递

时间:2011-07-26 00:42:02

标签: codeigniter

class Barcode extends CI_Controller 
{

    function index($barcode, $text='', $format="PNG", $quality=100, $width=160, $height=80, $type=1)

}

我有以下功能,我想在URL中传递以下内容:

http://localhost/index.php/barcode/index/1/Test%2FTest/PNG/100/256/80/1

但是在尝试这样做时我得到了404.

1 个答案:

答案 0 :(得分:0)

您是否需要首先通过$this->uri->segment('{n}')获取GET请求的所有部分?

我可能错了,但我不认为你这样做是对的。如果我要编写代码,我会执行以下操作:

function index()  
{
    $barcode = $this->uri->segment('3');  
    $text    = $this->uri->segment('4');  
    $format  = $this->uri->segment('5');  
    $quality = $this->uri->segment('6');  
    $width   = $this->uri->segment('7');  
    $height  = $this->uri->segment('8');  
    $type    = $this->uri->segment('9');  

    // continue with your code  
}