Re: Re: CONSTANTS and good coding practice

From: Date: Fri, 21 May 2004 15:04:36 +0000
Subject: Re: Re: CONSTANTS and good coding practice
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-186685@lists.php.net to get a copy of this message
* Thus wrote Greg Donald (destiney@destiney.com): > On Fri, 2004-05-21 at 08:37, Richard Davey wrote: > > Absolutely - and one of the best features of constants is their scope > > - being global in nature you can use them ANYWHERE which is very handy > > indeed! > > ANYWHERE except in code you plan to eval(). > > Funny how get_defined_constants() knows about all your CONSTANTS, but > eval() doesn't. Works fine: define('A_DEFINE', 'This is defined value'); eval('echo A_DEFINE;'); You were trying to do this: $val = "Defind {A_DEFINE}"; echo $val; Which wont work. Only variables can be expanded inside strings. Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#186685) next »