CodeIgniter Forums
How do I pass an argument to the index function? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: How do I pass an argument to the index function? (/thread-74719.html)



How do I pass an argument to the index function? - licogi - 10-29-2019

If I have

Code:
class Admin extends MY_Controller {
     public function index($task = NULL)
     {
       

     }
}
And a hyperlink that goes to base_url('admin/open/');
It will look for a method or function called open in my Admin controller. 
What if I want it to pass a url segement called open to the Index function? What do I do?



RE: How do I pass an argument to the index function? - dave friend - 10-29-2019

For the link, you could use example.com/admin/index/open

Or you need to use URI Routing. That can get troublesome if you have a lot of other admin methods that use the standard URL to controller/method/arg mapping.


RE: How do I pass an argument to the index function? - InsiteFX - 10-29-2019

You can also use the URI Class segment methods.

CodeIgniter User Guide - URI Class