codeigniter 경로 지원 은 물음표 가 있 는 재 작성 만 처리 할 수 있 습 니 다!

11278 단어 codeigniter
경로 설정http://www.* * * *. com / info / cat - 13479 - 13487 - 0 / 의 실제 방문 방법 은 info / lst? type = cat & v1 = $1 & v2 = $2 & v3 = $3 방법:
파일 수정: system / core / Router. php 방법:
_parse_routes()
//2014-11-16 12:19 add by f.z.b
if(strpos($val,'?') !== false){
    list($val,$queryString) = explode('?',$val);
    parse_str($queryString,$_GET);
}

전체 방법의 코드:
function _parse_routes()
{
   // Turn the segment array into a URI string
   $uri = implode('/', $this->uri->segments);

   // Is there a literal match?  If so we're done
   if (isset($this->routes[$uri]))
   {
      return $this->_set_request(explode('/', $this->routes[$uri]));
   }

   // Loop through the route array looking for wild-cards
   foreach ($this->routes as $key => $val)
   {
      // Convert wild-cards to RegEx
      $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));

      // Does the RegEx match?
      if (preg_match('#^'.$key.'$#', $uri))
      {
         // Do we have a back-reference?
         if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
         {
            $val = preg_replace('#^'.$key.'$#', $val, $uri);
         }

               //2014-11-16 12:19 add by f.z.b
               if(strpos($val,'?') !== false){
                   list($val,$queryString) = explode('?',$val);
                   parse_str($queryString,$_GET);
               }

         return $this->_set_request(explode('/', $val));
      }
   }

   // If we got this far it means we didn't encounter a
   // matching route so we'll set the site default route
   $this->_set_request($this->uri->segments);
}

설정 경로: application / config / routes. php
$route['info/cat-(:num)-(:num)-(:num)'] = 'info/lst/1?type=cat&v1=$1&v2=$2&v3=$3';
    public function lst($page = 1)
    {
        if ($page < 1) $page = 1;

        $type = $this->input->get('type');
        if($type == 'diqu'){
            $v1 = $this->input->get('v1');
            $v2 = $this->input->get('v2');
            $v3 = $this->input->get('v3');

        } else {

        }


    }

\ # 문 기본 값 입 니 다[email protected]

좋은 웹페이지 즐겨찾기