Weird results of "=="
| From: | Brian P. O'Donnell | Date: | Tue, 23 Aug 2005 21:28:00 +0000 |
| Subject: | Weird results of "==" | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-221213@lists.php.net to get a copy of this message | ||
Hello
I have the following code:
<?
$a = 252.73;
$b = 252.73;
$c = 0;
if ($a == ($b + $c))
{
// do the first thing
}
elseif ($a > ($b + $c))
{
// do the second thing
}
elseif ($a < ($b + $c))
{
// do the third thing
}
?>
Each of the three variables is derived by some earlier calculation, but for
testing purposes I have made sure that they end up being $a = $b and $c = 0.
I have tested for three different values (of $a) and gotten all three
results. That is, once the first block has executed, once the second block
and once the third block.
Am I missing something really obvious here?
How do I execute only the first block if indeed $a == ($b + $c) ?
Thank you for your help.
Brian