Basic PHP logic problem
$this->totplpremium is 2400
$this->minpremiumq is 800
So why would this ever return true?开发者_如何学编程!
if ($this->totplpremium < $this->minpremiumq){
The figures are definitely correct and I am definitely using the 'less than' symbol. I can't work it out.
Maybe there's some kind of conversion problem. Try use
var_dump($this->totplpremium);
var_dump($this->minpremiumq);
if ($this->totplpremium < $this->minpremiumq){
...
}
to see if the datatypes are allright
EDIT: There are tools that enables you to debug your code more easily than using debugging outputs - http://xdebug.org/ (an extension for PHP that enables you debugging) and http://en.wikipedia.org/wiki/PHPEd (It's commercial. I don't know if there's an alternative.)
Try wrapping the 'numbers' with intval:
if (intval($this->totplpremium) < intval($this->minpremiumq)){
//...
}
If this works as expected then you really need to check what types totplpremium and minpremiumq are by using gettype, for example:
print(gettype($this->totplpremium));
print(gettype($this->minpremiumq));
With that info you should be able to pinpoint your error.
As an alphabetical comparison, the following statement is true:
"800" > "2400"
(because 8 is greater than 2)
<?php
$totplpremium="2400 ";
$minpremiumq="800";
var_dump(($totplpremium < $minpremiumq)?true:false);
var_dump(((int)$totplpremium < (int)$minpremiumq)?true:false);
?>
I'd guess you should either double check where these values come from OR make sure they are integers.
Good luck coding!
精彩评论