Re: [PHP] comparison operator

2005-03-09 Thread Richard Lynch
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/off value

Re: [PHP] comparison operator

2005-03-09 Thread Jason Barnett
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? |

RE: [PHP] Comparison Operator

2005-01-11 Thread Ford, Mike
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 break

RE: [PHP] Comparison Operator

2005-01-10 Thread Jay Blanchard
[snip] Could anyone tell me why this code echos? ?php $value = 0; $curval = 'A'; if ($value == $curval) { echo WTH, Overbr; } ? [/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

Re: [PHP] Comparison Operator

2005-01-10 Thread tg-php
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

Re: [PHP] Comparison Operator

2005-01-10 Thread trobi
Chadwick, Russell wrote / napĂ­sal (a): Could anyone tell me why this code echos? ?php $value = 0; $curval = 'A'; if ($value == $curval) { echo WTH, Overbr; } ? Try === If you use == $value is compared to $curval $value is integer so php converts $curval to integer so it contains no digtis so

Re: [PHP] Comparison Operator

2005-01-10 Thread Brad Pauly
On Mon, 10 Jan 2005 10:26:16 -0800, Chadwick, Russell [EMAIL PROTECTED] wrote: Could anyone tell me why this code echos? ?php $value = 0; $curval = 'A'; if ($value == $curval) { echo WTH, Overbr; } ? The string is converted to an integer when compared with an integer. See this

RE: [PHP] Comparison Operator

2005-01-10 Thread Chadwick, Russell
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: Could anyone tell me why this code echos

RE: [PHP] Comparison Operator

2005-01-10 Thread Richard Lynch
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 better way

RE: [PHP] Comparison Operator

2004-07-01 Thread 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 if they aren't included, then does

Re: [PHP] Comparison Operator

2004-07-01 Thread Gabe
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,

Re: [PHP] Comparison Operator

2004-07-01 Thread Curt Zirzow
* 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 if they