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

If I have

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?

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.

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 )

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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