Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14343

codeigniter rouer.php code analysis

$
0
0
hi bro,look at below the code:
protected function _set_request($segments = array())
{
  $segments = $this->_validate_request($segments);
  // If we don't have any segments left - try the default controller;
  // WARNING: Directories get shifted out of the segments array!
  if (empty($segments))
  {
     $this->_set_default_controller();
     return;
  }

  if ($this->translate_uri_dashes === TRUE)
  {
     $segments[0] = str_replace('-', '_', $segments[0]);
     if (isset($segments[1]))
     {
        $segments[1] = str_replace('-', '_', $segments[1]);
     }
  }

  $this->set_class($segments[0]);
  if (isset($segments[1]))
  {
     $this->set_method($segments[1]);
  }
  else
  {
     $segments[1] = 'index';
  }

  array_unshift($segments, NULL);
  unset($segments[0]);
  $this->uri->rsegments = $segments;
}

I don't know at the code last why use array_unshift and unset?
I mean that we can delete the code,what's its function?

Viewing all articles
Browse latest Browse all 14343

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>