Sebastian wrote:
i never really used constants before so this may sound stupid..
you could use constants and still sound stupid.
- that would be 'constantly sounding stupid' ;-)
when you define a constant using define() and want to return true/false
is this logical:
yes, if a little
On Wed, 2005-07-27 at 17:17 -0400, Sebastian wrote:
i never really used constants before so this may sound stupid..
when you define a constant using define() and want to return true/false
is this logical:
if($bars == 3)
{
define('BAR', 1);
}
then:
if(BAR)
{
// bars is
André Medeiros wrote:
On Wed, 2005-07-27 at 17:17 -0400, Sebastian wrote:
i never really used constants before so this may sound stupid..
when you define a constant using define() and want to return true/false
is this logical:
if($bars == 3)
{
define('BAR', 1);
}
then:
if(BAR)
{
...
[snip]
if($bars == 3)
{
define('BAR', 1);
}
then:
if(BAR)
{
That's an incorrect use for constants. Use variables for that =]
WHY?
[/snip]
Because the constant can be variable in this case. Consider (this is old
school, and we all know that I am the definition of old school) the
definition
On Thu, 2005-07-28 at 14:41 +0200, Jochem Maas wrote:
André Medeiros wrote:
On Wed, 2005-07-27 at 17:17 -0400, Sebastian wrote:
i never really used constants before so this may sound stupid..
when you define a constant using define() and want to return true/false
is this logical:
Exactly,
CONSTANTS are ... eternal truths to the program, they shouldn't
change, constants should not be changing based on arguments being
passed, or other variables.
by definition, it's no longer a constant, and a misuse of the define
() function.
On Jul 28, 2005, at 8:46 AM, Jay
Sebastian wrote:
i never really used constants before so this may sound stupid..
when you define a constant using define() and want to return true/false
is this logical:
if($bars == 3)
{
define('BAR', 1);
}
then:
if(BAR)
{
// bars is true
}
or should i need to do an else statement as
Jay Blanchard wrote:
[snip]
if($bars == 3)
{
define('BAR', 1);
}
then:
if(BAR)
{
That's an incorrect use for constants. Use variables for that =]
WHY?
[/snip]
Because the constant can be variable in this case. Consider (this is old
school, and we all know that I am the definition of
John Nichel wrote:
Jay Blanchard wrote:
[snip]
if($bars == 3)
{
define('BAR', 1);
}
then:
if(BAR)
{
That's an incorrect use for constants. Use variables for that =]
WHY?
[/snip]
Because the constant can be variable in this case. Consider (this is old
school, and we all know that
John Nichel wrote:
Jay Blanchard wrote:
[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...
}
Jochem Maas wrote:
now that was exactly my reasoning ... but I very much appriciate the input
of the more experienced/older/classically-trained (as apposed to my
completely
-self-taught-not-backed-up-with-any-solid-computer-science-theory-skills)
guys out there (hey Jay it's a compliment ;-)
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
[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
[snip]
now that was exactly my reasoning ... but I very much appriciate the
input
of the more experienced/older/classically-trained (as apposed to my
completely
-self-taught-not-backed-up-with-any-solid-computer-science-theory-skills
)
guys out there (hey Jay it's a compliment ;-)
Jay's
i never really used constants before so this may sound stupid..
when you define a constant using define() and want to return true/false
is this logical:
if($bars == 3)
{
define('BAR', 1);
}
then:
if(BAR)
{
// bars is true
}
or should i need to do an else statement as well:
if($bars
i never really used constants before so this may sound stupid..
when you define a constant using define() and want to return true/false
is this logical:
http://us2.php.net/defined
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
16 matches
Mail list logo