10. URI Class
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
• The URI Class provides functions that help
you retrieve information from your URI
strings
• Note: This class is initialized automatically
by the system so there is no need to do it
manually..
11. URI Class
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
• $this->uri->segment(n)
• example:
http://example.com/index.php/news/local/metro/crime_is_up
• The segment numbers would be this:
1. news
2. local
3. metro
4. crime_is_up
13. URI Class
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
• $this->uri->uri_string()
Returns a string with the complete URI
• $this->uri->total_segments()
Returns the total number of segments.
• $this->uri->segment_array()
Returns an array containing the URI segments
15. Libraries
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
• File names must be capitalized. For example: Myclass.php
• Class declarations must be capitalized. For
example: class Myclass
• Class names and file names must match.
•Class declarations must be capitalized. For example: class Myclass
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Someclass {
public function some_function()
{
}
}
/* End of file Someclass.php */
16. Libraries
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
• Loading the library & Calling some function.
•Class declarations must be capitalized. For example: class Myclass
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class mycontroller{
public function my_function()
{
$this->load->library('someclass');
$this->someclass->some_function();
}
}
/* End of file Someclass.php */