johnsmith153 Posted December 1, 2010 Share Posted December 1, 2010 Imagine a site programmed using full OOP. Where would you store information like this: $companyName = "ABC Ltd"; $companyPhone = "02476 999 999"; $companyAddress etc... Would you just define them in the public scope? (and use global or pass them in when needed??) Is there a better way? They will be needed in more places than just a navigation bar and would be needed by more than one class. Quote Link to comment https://forums.phpfreaks.com/topic/220309-oop-where-define-companyname-etc/ Share on other sites More sharing options...
trq Posted December 1, 2010 Share Posted December 1, 2010 Generally, simple values like this would either be stored in a config file or a database. Either way, you would access them via a Model implementation of some sort. Quote Link to comment https://forums.phpfreaks.com/topic/220309-oop-where-define-companyname-etc/#findComment-1141643 Share on other sites More sharing options...
dawsba Posted December 1, 2010 Share Posted December 1, 2010 2 easy choices, 1 being define : define("COMPANYNAME", "ABC Ltd"); defines are ok, but if you need to change them on the fly not so good. or my personal favorite session $_SESSION[COMPANYNAME] = "ABC Ltd"; Quote Link to comment https://forums.phpfreaks.com/topic/220309-oop-where-define-companyname-etc/#findComment-1141645 Share on other sites More sharing options...
trq Posted December 1, 2010 Share Posted December 1, 2010 2 easy choices, 1 being define : define("COMPANYNAME", "ABC Ltd"); defines are ok, but if you need to change them on the fly not so good. or my personal favorite session $_SESSION[COMPANYNAME] = "ABC Ltd"; $_SESSION's store data related to a specific user, not the overall application. There is no point duplicating your data all over the place. Quote Link to comment https://forums.phpfreaks.com/topic/220309-oop-where-define-companyname-etc/#findComment-1141661 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.