Cannot call the same static method from identical method from the same class Cannot call the same static method from identical method from the same class codeigniter codeigniter

Cannot call the same static method from identical method from the same class


Calling functions from another controller breaks MVC and puts you in the HMVC realm.

Please take a look at this thread, and also CodeIgniter's Modular Extensions (HMVC) Plugin if you really need to do this.


Why don't you create MY_Controller which extends the CI_Controller where you put your reusable code?


Actually - you are mistaken. Your "index" code does not work either.

I just pasted all your code above into a clean version of CI 2.1.2 and the index function ALSO returns the same error.

So perhaps your computer has something cached, or you have some other code elsewhere that is making you think it is working. But it does not work.

Anyway - the real question is why are you trying to call a controller from another controller? That is not a good MVC approach. Your "_menu()" function should be located in a library - that is where it belongs.

Or put the _menu() code into "MY_Controller" and have both controllers extend MY_Controller.

Or put the _menu() code into a helper.

Basically there are three better ways you could approach this.