Re: define (true/false)
| From: | Edward Vermillion | Date: | Thu, 28 Jul 2005 13:41:29 +0000 |
| Subject: | Re: define (true/false) | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-219508@lists.php.net to get a copy of this message | ||
John Nichel wrote:
Jay Blanchard wrote:I do the same thing. Another thing I like about using "variable" constants in *some* cases is that they can't be reset to something else. So if I do something boneheaded in my application, it's not gonna screw everything up, or at least not leave me open to some kind of unforseen attack.[snip] never want to use a variable to determine a constant because the variable is not likely to be the same (that is why we call them variables) on any iteration. Using constants in expressions is OK, for instance if(BAR == $foo){ ...stuff... } But modifying a constant is a no-no.I may be misunderstanding you here, but I don't see why you would not want to use a variable to define a constant. I do it from time to time, most common would be in a config document where I'll check if the page is being accessed via http or https, and define a constant based on that. I know I could use a variable for this, but I like using the constant for it's global scope in that case.