CI_URI::segment PHP Method

segment() public method

Fetch URI Segment
See also: CI_URI::$segments
public segment ( integer $n, mixed $no_result = NULL ) : mixed
$n integer Index
$no_result mixed What to return if the segment index is not found
return mixed
    public function segment($n, $no_result = NULL)
    {
        return isset($this->segments[$n]) ? $this->segments[$n] : $no_result;
    }

Usage Example

Esempio n. 1
0
 public function segment($n, $no_result = NULL)
 {
     if (!is_numeric($n)) {
         if (array_key_exists($n, $this->uri_parameters)) {
             $n = $this->uri_parameters[$n];
         } else {
             return $no_result;
         }
     }
     return parent::segment($n, $no_result);
 }