|
Posted by Dana Cartwright on 01/09/06 17:10
"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.
Navigation:
[Reply to this message]
|