Codeigniter กับการใช้ URI Class เพื่อเรียก url
-

URI Class มีวิธีการที่ช่วยคุณดึงข้อมูลจากสตริง URI ของคุณ หากคุณใช้การกำหนดเส้นทาง URI คุณยังสามารถดึงข้อมูลเกี่ยวกับเซ็กเมนต์ที่กำหนดเส้นทางใหม่ได้
1. การใช้งานทั่วไป
สมมุติ URL คือ http://example.com/index.php/news/local/metro/crime_is_up
เราสามารถเรียกใช้งาน URI Segment ได้ด้วยคำสั่ง $this->uri->segment(ตำแหน่ง)
$this->uri->segment(1) คือ news
$this->uri->segment(2) คือ local
$this->uri->segment(3) คือ metro
$this->uri->segment(4) คือ crime_is_up
2. การใช้งาน Slash Segment
3. การใช้งาน URI String