• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.