views:

49

answers:

4

I want to write a new controller file f.g. aaa.php, there is a function bbb() in aaa.php,

how can i enter aaa.php's bbb(),

The example files are begin with welcome.php's index() function.

how can I change that to begin with my new controller file?

A: 

You want to have a separate function run as the Controller's default function? Why not just call this separate function from index()? Beyond this, I'm not really sure what you're asking...the CodeIgniter user_guide is rather extensive if you haven't looked through it.

treeface
A: 

If you want to use the bbb function of the aaa controller, you just enter this in the url:

www.mysite.com/aaa/bbb/

GSto
+2  A: 

If you provide nothing to the base URL, CI will always assume you want the index action. Like localhost/foo will call foo's index() action. With localhost/foo/bar, you will call foo's bar() action. If you want to call localhost and you want to access foo's index(), you need to check that $route['default_controller'] = 'foo'; is correctly setup in your config.php. (If that's not working, check the .htaccess and the index.php to add it manually)

DrColossos
A: 

As Gsto said, to call bbb function enter the url: mysite.com/aaa/bbb

If you want mysite.com/aaa to call bbb() instead of index() by default, your going to want to create the _remap() function in aaa.php controller to call bbb() instead.
See: CI Controllers - Functions Docs

Mitchell McKenna