URI 細分

例如,請考慮以下 URI:

http://stackoverflow.com/questions/some-number/how-can-i-do-this/others

Segment 允許檢索特定的段表單 URI 字串,其中 n 是段號。細分從左到右編號。例如,以下程式碼:

$this->uri->segment(n)

用於從 URI 中檢索特定段,其中 n 是段號。

echo $this->uri->segment(0);//it will print stackoverflow.com
echo $this->uri->segment(1);//it will print questions
echo $this->uri->segment(2);//it will print some-number
echo $this->uri->segment(3);//it will print how-can-i-do-this
echo $this->uri->segment(4);//it will print others