Jump to content

OOP - where define $companyName etc.


johnsmith153

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/220309-oop-where-define-companyname-etc/
Share on other sites

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.

 

:)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.