![]() |
How to go about using frequent functions - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to go about using frequent functions (/showthread.php?tid=55297) |
How to go about using frequent functions - El Forum - 10-19-2012 [eluser]Unknown[/eluser] I'm experiencing codeigniter for the first time, yet I've been programming in PHP since '02 or so. I have gone through some tutorials, and get the basic structure and I love it! As a first-dev I'm going to throw up basic "user system" functionality. How is it preferred to go out about using frequently used functions/ classes such as a User class? Should you extend the User class on every page that you will use it? as such: (note this isn't my actual code, just testing theory. controllers/user.php Code: class User extends CI_Controller controllers/homepage.php Code: class Homepage extends User How to go about using frequent functions - El Forum - 10-19-2012 [eluser]PhilTem[/eluser] Well, there are two ways to solving your problem. Number one would be something called a MY_Controller which you kinda already created with your user-controller. However, to allow working with CI you should call it MY_Controller. Have a look at the user's guide. Number two would be to use a library or a helper, that you autoload and then can use in every controller, model, view, library, ... How to go about using frequent functions - El Forum - 10-19-2012 [eluser]Aken[/eluser] A library and/or model makes more sense for user management, personally. |