Welcome Guest, Not a member yet? Register   Sign In
codeigniter rouer.php code analysis
#1

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?
Reply
#2

Not having a 0 element, bro.
Reply
#3

I'm sorry bro,I don't understand your mean.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB