CodeIgniter Forums
What does 'the segments passed to your function will be the re-routed ones.' mean exactly - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: What does 'the segments passed to your function will be the re-routed ones.' mean exactly (/showthread.php?tid=56694)



What does 'the segments passed to your function will be the re-routed ones.' mean exactly - El Forum - 01-11-2013

[eluser]Unknown[/eluser]
Can someone please explain? with an example ?

http://ellislab.com/codeigniter/user-guide/general/controllers.html#passinguri

Thanks


What does 'the segments passed to your function will be the re-routed ones.' mean exactly - El Forum - 01-11-2013

[eluser]Aken[/eluser]
It means that the method's parameters will ignore the URL in the browser if the URL has been moved using routes.

Example controller:

Code:
class Example extends CI_Controller {

public function yourmethod($var1, $var2)
{
  var_dump($var1, $var2);
}

}

Example route:

Code:
$route['fakecontroller/fakemethod/newvar/newvar2'] = 'example/yourmethod/oldvar/oldvar2';

If you go to your routed URL, http://www.example.com/fakecontroller/fakemethod/newvar/newvar2, you'll see that those extra segments are not passed to the method's params. It will only use the routed (or "standard") URL segments.