MY_Controller vs. Foo_Controller |
[eluser]pbarney[/eluser]
What is the functional difference between: Code: class MY_Controller extends Controller ...and... Code: class LoginRequired_Controller extends Controller They're both extending "Controller", so what's the point of using MY_? Thanks for any insight! Peter
[eluser]J Maxwell[/eluser]
CodeIgniter will automatically look for and load "MY_", although if you change the setting in the config file then you can get it to load "LoginRequired_" automatically instead? Although then all of your custom overrides to core libraries would have to be "LoginRequired". If MY_ is bothering you, why not change it to "Site_" or "Wizard_" or something equally cool? Ahem.
[eluser]pbarney[/eluser]
Ah, you've cleared it up. It's that "MY_" is autoloaded whereas the other is not. I don't have a problem with the prefix; I just didn't understand it's purpose. Thanks!
[eluser]J Maxwell[/eluser]
Hehe I did have a problem with the prefix, just sounded a little unprofessional in code that sometimes the client would see, so changed it to my company initials. Glad to help, John
[eluser]pbarney[/eluser]
So a way around all this (if you don't mind PHP 5 compatibility) is to add an auto-load function to config.php: Code: /* Thanks to Phil Sturgeon, for this bit of usefulness. |
Welcome Guest, Not a member yet? Register Sign In |