Reply to Re: [PHP] define (true/false)

Your name:

Reply:


Posted by Vidyut Luther on 11/14/05 11:22

On Jul 28, 2005, at 9:41 AM, Edward Vermillion wrote:

> [snip]
>> 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.
>>
>
> 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]

For this, it's ok to do, but what I thought you were doing was
something along the lines of

if(3 == $bar) {
define('IAMCONSTANT',"3 bars");
} else {
define('IAMCONSTANT',"not 3 bars");
}

it should just be,

if(defined(USINGHTTPS) or not..

The above example is oversimplified on purpose, but I also don't
practice if(y == x) { define constant = value}, it's usually used to
set things true/false
but not assign a different value to constant.

variables like USINGHTTPS, are more of a "environment variable"
rather than a constant

think of it like $_SUPERGLOBALS .. are variables.. even though they
are available everywhere.. things like phpversion() are constants,
until the next time you compile and install.

[Back to original 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

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