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
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.

 

:)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.