Please help, this is driving me nuts!
Can anybody spot a difference/something wrong with either of these? In case you haven't already guessed, the switch statement doesn't resolve like i'd expect it to. The nested if does fine though.
The specific problem comes when $hcap-$this->si (should) equate to 0, i get a 2 returned rather than a 1.
I'm commenting out each code respectively, so the input data is the always the same, but the output varies depending on which i use. I must be missing something, i just don't know what!
Cheers
Can anybody spot a difference/something wrong with either of these? In case you haven't already guessed, the switch statement doesn't resolve like i'd expect it to. The nested if does fine though.
The specific problem comes when $hcap-$this->si (should) equate to 0, i get a 2 returned rather than a 1.
I'm commenting out each code respectively, so the input data is the always the same, but the output varies depending on which i use. I must be missing something, i just don't know what!
Cheers
Code:
switch($hcap - $this->si){
case ($hcap - $this->si >= 18):
return 2;
break;
case ($hcap - $this->si >= 0):
return 1;
break;
case ($hcap - $this->si < 0):
return 0;
break;
}
Code:
if($hcap - $this->si >= 18){
return 2;
}else if($hcap - $this->si >= 0){
return 1;
}else if($hcap - $this->si < 0){
return 0;
}