Page 2 of 2

Posted: Tue Mar 07, 2006 6:42 pm
by Chris Corbyn
Gambler wrote:
onfigurations generally should not ever be altered at run times
I don't see why not. Configuration can be seen as a set of defaults.
Exactly... But it any case why can't you use constants in a class? "const" keyword in PHP5.

Posted: Tue Mar 07, 2006 6:56 pm
by alex.barylski
Jcart wrote:
Hockey wrote:Just out of curiosity...why use a 'Config' class???

Do you include update/delete file operations in these classes for easy end user changes???

I personally just use an multi-dimensional array... :)
configurations generally should not ever be altered at run times, so your best bet is typically a constant.
I agree for the most part...but I use multi-dimensional arrays for a reason and that is to remove my configuration from any typical namespace...

Code: Select all

$GLOBALS['PRODNAME']['CONFIG']['SECTION'] = 'Some string or array maybe';
Also, constants aren't available in PHP 4 (as you likely know)...except as define in which case it allows nothing other than scalars...many config settings in my apps are arrays, etc...

I don't wish to develop in PHP5 yet :)

For those reasons and a few others I always use multidimensional arrays...which aren't easily modified at runtime :)

Posted: Tue Mar 07, 2006 7:01 pm
by alex.barylski
Gambler wrote:
onfigurations generally should not ever be altered at run times
I don't see why not. Configuration can be seen as a set of defaults.
I think it's a matter of opinion really...

IMHO however configuration is a static entity...there not variables in the typical sense...when changed it should be a 'hard' change.

Configuration I consider application wide...as in...every user sees any changes made...whereas settings are more geared towards user experience or user profile, etc...

Settings I typically store in a database for obvious reasons...but again...being stored in a database kinda makes them static in a runtime variable sense.

This is just my opinion of course :)

Posted: Tue Mar 07, 2006 7:03 pm
by alex.barylski
d11wtq wrote:
Gambler wrote:
onfigurations generally should not ever be altered at run times
I don't see why not. Configuration can be seen as a set of defaults.
Exactly... But it any case why can't you use constants in a class? "const" keyword in PHP5.
Thats what I would do if the option was available in anything less than PHP4...

Until I switch to 5...I'll rely on good old fashioned disipline(sp.) :)