• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I pass an argument to the index function?

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

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

#3
You can also use the URI Class segment methods.

CodeIgniter User Guide - URI Class
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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