You are here: Re: how do I make a variable global « PHP Programming Language « IT news, forums, messages
Re: how do I make a variable global

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация