Changeset 444

Show
Ignore:
Timestamp:
08/29/2007 02:38:12 PM (15 months ago)
Author:
Geert
Message:
  • Added parameter for alternative default return value to URI->segment()
  • Added URI->total_segments()
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/URI.php

    r412 r444  
    33class URI_Core extends Router { 
    44 
    5         public function segment($index = 1) 
     5        /** 
     6         * Retrieve a specific URI segment 
     7         * 
     8         * @access      public 
     9         * @param       int 
     10         * @param       mixed 
     11         * @return      mixed 
     12         */ 
     13        public function segment($index = 1, $default = FALSE) 
    614        { 
    715                $index = (int) $index - 1; 
    816 
    9                 return isset(self::$segments[$index]) ? self::$segments[$index] : FALSE; 
     17                return isset(self::$segments[$index]) ? self::$segments[$index] : $default; 
    1018        } 
    1119 
     20        /** 
     21         * Returns an array containing all the URI segments 
     22         * 
     23         * @access      public 
     24         * @return      array 
     25         */ 
    1226        public function segment_array() 
    1327        { 
     
    2337        } 
    2438 
     39        /** 
     40         * Returns the complete URI as a string 
     41         * 
     42         * @access      public 
     43         * @return      string 
     44         */ 
    2545        public function string() 
    2646        { 
    2747                return implode('/', self::$segments); 
    2848        } 
     49         
     50        /** 
     51         * Returns the total number of URI segments 
     52         * 
     53         * @access      public 
     54         * @return      integer 
     55         */ 
     56        public function total_segments() 
     57        { 
     58                return count(self::$segments); 
     59        } 
    2960 
    3061} // End URI Class