Reputation: 15660
i have the following URI:
http://mysite/myapp/index.php/test/testURL/CAN-q1/300-48/fa1/59//can-a2
You'll notice that the 7th URI segment is not set.
I need to test for these types of scenarios.
I've tried a few different things but i can't seem to get it to work. What's happening is segment 8 is being assigned as segment 7.
Here's some test code I've been playing with this morning:
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>';
And the results come back as:
3 - CAN-q1
4 - 300-48
5 - fa1
6 - 59
7 is: can-a2
8 -
Based on reading the codeigniter manual, i would have expected that segment 7 would contain a 0 or whatever i passed as the second parameter in the uri->segment() method.
Can you tell me where I'm going wrong? Thanks.
Upvotes: 1
Views: 2858
Reputation: 15660
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.
Upvotes: 1