1

我有以下 URI:

    http://mysite/myapp/index.php/test/testURL/CAN-q1/300-48/fa1/59//can-a2

您会注意到第 7 个 URI 段未设置。我需要测试这些类型的场景。
我尝试了一些不同的东西,但我似乎无法让它工作。发生的事情是第 8 段被分配为第 7 段。这是我今天早上一直在玩的一些测试代码:

    echo '3 - '. $this->uri->segment(3); 
    echo '<BR>';
    echo '4 - '. $this->uri->segment(4); 
    echo '5 - '. $this->uri->segment(5); 
    echo '<BR>';
    echo '6 - '.$this->uri->segment(6);
    echo '<BR>';
    $test = $this->uri->segment(7,0);   
    echo '7 is: '.$test;
    echo '<BR>';
    echo '8 - '. $this->uri->segment(8);
    echo '<BR>';

结果返回为:

 3 - CAN-q1
 4 - 300-48
 5 - fa1
 6 - 59
 7 is: can-a2
 8 - 

根据阅读 codeigniter 手册,我预计第 7 段将包含 0 或我作为 uri->segment() 方法中的第二个参数传递的任何内容。

你能告诉我哪里出错了吗?谢谢。

4

1 回答 1

1

I just decided to pass a space instead of an empty URI, based on comments that others have made that you can't have a empty segment. This seems to have resolved the problem. Thanks to everyone who commented.

于 2012-12-17T19:12:28.383 回答