标签:mnt target http 输入 segment get display lead ota
1. URI类
须知:
http协议中的URI和URL有什么区别: https://www.zhihu.com/question/21950864
1 <?php 2 //假设当前URL为 http://xf.com/index.php/foods/dinner/noodle 3 4 /** 5 * segment($n[, $no_result=NULL]) 6 * URI路由: rsegment($n[, $no_result=NULL]) 7 * 从URI中获取指定段 8 */ 9 $arr = $this->uri->segment(2, 0); //dinner 10 11 /** 12 * slash _segment($n[, $where=‘trailing‘]) 13 * URI路由: slash_rsegment($n[, $where=‘trailing‘]) 14 * 根据第二个的参数决定是否在返回结果的前面或者后面添加斜杠 15 */ 16 $arr = $this->uri->flash_segment(3); // noodles 17 $arr = $this->uri->flash_segemnt(3, ‘leading‘); // /noodle 18 $arr = $this->uri->flash_segment(3, ‘both‘); // /noodle/ 19 20 /** 21 * uri_to_assoc($n=3[, $default=array()]) 22 * URI路由: ruri_to_assoc($n=3[, $default=array()]) 23 * 将 URL的段转换为一个包含键值对的关联数组 24 */ 25 //假设当前URL为 index.php/user/search/name/joe/location/UK/gender/male 26 $arr = $this->uri->uri_to_assoc(3); 27 $_default = array(‘name‘, ‘gender‘, ‘location‘, ‘type‘, ‘sort‘); 28 $arr = $this->uri->uri_to_assoc(3, $_default); 29 //返回结果如下 30 $arr = array( 31 ‘name‘ => ‘joe‘, 32 ‘location‘ => ‘UK‘, 33 ‘gender‘ => ‘male‘ 34 ); 35 36 /** 37 * assoc_to_uri($array) 38 * 根据输入关联数组生成一个URI字符串 39 */ 40 $arr = array( 41 ‘product‘ => ‘shoes‘, 42 ‘size‘ => ‘large‘, 43 ‘color‘ => ‘red‘ 44 ); 45 $str = $uri_str = $this->uri->assoc_to_uri($arr); //product/shoes/size/large/color/red 46 47 /** 48 * uri_string() 49 * URI路由: ruri_string() 50 * 返回一个相对的URI 51 */ 52 $str = $this->uri->string(); //foods/dinner/noodle 53 54 /** 55 * total_segments() 56 * total_rsegments() 57 * 返回URI的总段数 58 */ 59 $n = $this->uri->total_segment(); 60 61 /** 62 * segment_array() 63 * rsegment_array() 64 * 返回URI所有的段组成的数组 65 */ 66 $arr = $this->uri->segment_array(); 67 //结果为: 68 $arr = array( 69 1 => ‘food‘, 70 2 => ‘dinner‘, 71 3 => ‘noodle‘ 72 ); 73 74 ?>
标签:mnt target http 输入 segment get display lead ota
原文地址:http://www.cnblogs.com/pxf-ohyeah/p/7976882.html