Is there any way to create a function that works for all controllers in Codeigniter at init?
In Zend there is a application/Bootstrap.php, i need some solution like that.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could extend the native
CI_Controllerclass and create aMY_Controllerclass that all of your application’s controllers would extend. Methods in theMY_Controllerclass would then be available to every controller that extends it. You could also put code in theMY_Controllerconstructor that would be executed each time a child controller was constructed.I don’t remember exactly how the Bootstrap file works in Zend, but if this sounds like a viable solution the Creating Core System Classes section of the documentation explains how to extend the native controller.