Re: Re: CONSTANTS and good coding practice
| From: | Greg Donald | Date: | Fri, 21 May 2004 14:24:53 +0000 |
| Subject: | Re: Re: CONSTANTS and good coding practice | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-186681@lists.php.net to get a copy of this message | ||
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.
I made this little function so I could use defined CONSTANTS in HTML
templates that get eval()'d.
function makeConstants() {
foreach(get_defined_constants() as $k=>$v) $GLOBALS[$k] = $v;
}
--
Greg Donald
destiney@destiney.com