Richard Lynch wrote:
>>i ran into this problem and i dont remember how i worked around it.
>
>
> http://php.net/isset
>
>
I would also use isset. Or you can use the identical (===) comparison
instead of the equivalent (==) comparison to check for 0.
--
Teach a man to fish...
NEW? | http://www.c
> i ran into this problem and i dont remember how i worked around it.
http://php.net/isset
> if($_REQUEST['value'] == 1)
> {
> // do something
> }
> else if($_REQUEST['value'] == 0)
> {
> // do something
> }
>
> even if i don't do ?value=0 its always prints something.. i want to make
> an
> on
i ran into this problem and i dont remember how i worked around it.
if($_REQUEST['value'] == 1)
{
// do something
}
else if($_REQUEST['value'] == 0)
{
// do something
}
even if i don't do ?value=0 its always prints something.. i want to make an
on/off value based on the value of the url.. 1 for
To view the terms under which this email is distributed, please go to
http://disclaimer.leedsmet.ac.uk/email.htm
On 10 January 2005 21:20, Chadwick, Russell wrote:
> The function this is from sometimes uses $_POST or $_GET input, so
> sometimes its comparing 1337 with '1337' and === would brea
Chadwick, Russell wrote:
>
> The function this is from sometimes uses $_POST or $_GET input, so
> sometimes its comparing 1337 with '1337' and === would break that.
>
> so I'll have to use something like:
>
> if (($value == $curval) && !(is_string ($curval) && ($value == 0)))
>
> unless there is a
unless there is a better way
From: Brad Pauly [mailto:[EMAIL PROTECTED]
Sent: Mon 2005-01-10 11:41
To: Chadwick, Russell
Cc: php-general@lists.php.net
Subject: Re: [PHP] Comparison Operator
On Mon, 10 Jan 2005 10:26:16 -0800, Chadwick, Russell
<[EMAIL PROTECTED]> wrote:
&
On Mon, 10 Jan 2005 10:26:16 -0800, Chadwick, Russell
<[EMAIL PROTECTED]> wrote:
>
> Could anyone tell me why this code echos?
>
> $value = 0;
> $curval = 'A';
> if ($value == $curval) {
> echo "WTH, Over";
> }
> ?>
The string is converted to an integer when compared with an integer.
See
Chadwick, Russell wrote / napĂsal (a):
Could anyone tell me why this code echos?
";
}
?>
Try ===
If you use ==
$value is compared to $curval
$value is integer so
php converts $curval to integer
so it contains no digtis so
it assumes that $curval=0;
why it is.
trobi
--
PHP General Mailing List
Ahh.. the trick question. hah.. Ok, let me see if I remember this (although it
doesn't seem to follow the logic in my head.. I know someone else will explain
it better but let me take a crack at it):
When comparing a two different variable types that PHP thinks it knows how to
compare, it will
[snip]
Could anyone tell me why this code echos?
";
}
?>
[/snip]
Because it has an echo statement in it. And '==' is not '==='
>From http://us3.php.net/manual/en/language.operators.comparison.php
"If you compare an integer with a string, the string is converted to a
number. If you compare two
Could anyone tell me why this code echos?
";
}
?>
* Thus wrote Michael Sims:
> Gabe wrote:
> > I was looking at the comparison operators page and noticed that these
> > two operators were listed as "PHP4 only". Is that an error, or are
> > they really not used in PHP5? I don't want to use them if they're
> > going to break when I upgrade. And i
Michael Sims wrote:
Gabe wrote:
I was looking at the comparison operators page and noticed that these
two operators were listed as "PHP4 only". Is that an error, or are
they really not used in PHP5? I don't want to use them if they're
going to break when I upgrade. And if they aren't included, t
Gabe wrote:
> I was looking at the comparison operators page and noticed that these
> two operators were listed as "PHP4 only". Is that an error, or are
> they really not used in PHP5? I don't want to use them if they're
> going to break when I upgrade. And if they aren't included, then
> does s
I was looking at the comparison operators page and noticed that these
two operators were listed as "PHP4 only". Is that an error, or are they
really not used in PHP5? I don't want to use them if they're going to
break when I upgrade. And if they aren't included, then does something
else repl
15 matches
Mail list logo