|
Posted by windandwaves on 01/10/06 03:00
Dana Cartwright wrote:
> "windandwaves" <winandwaves@coldmail.com> wrote in message
> news:_3iwf.13541$vH5.701435@news.xtra.co.nz...
>> The reason i am using a variable is that these are easier to
>> customise. I have file with standard values and then a config file
>> that overrides any variable that should be customised for a
>> particular application. Defined constants can only be defined once.
>>
>
> While you can't DEFINE something more than once, you can test to see
> if something is already defined, and this enables you can use a
> system of overrides.
>
> I use two files, one containing overriding defines, and one
> containing the default or factory values.
>
> Let's say you want to override the value of 'FOO'. In your override
> file, you say:
>
> define( 'FOO' , 'myFoo' );
>
> In the main configuration file, 'foo' is defined like this:
>
> if ( !defined( 'FOO' ) )
> define( 'FOO' , 'bar' );
>
> which only defines 'FOO' if it's not already defined in the override
> file.
> You have to INCLUDE your overriding defines file first.
Hmm, thank you for that. That is a great idea. I actually use this concept
now, and I dont even think you need to add the if ( !defined( 'FOO' ) )
bit because, once defined, you can not redefine items.
Navigation:
[Reply to this message]
|