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


Messages In This Thread
codeigniter rouer.php code analysis - by mme7wan - 10-18-2016, 07:55 PM
RE: codeigniter rouer.php code analysis - by Narf - 10-19-2016, 05:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB