我有以下计算:
$this->count = float(44.28)
$multiple = float(0.36)
$calc = $this->count / $multiple;
$calc = 44.28 / 0.36 = 123
现在我想检查我的变量$calc
是否为整数(有小数)。
我试过这样做if(is_int()) {}
,但这不起作用,因为$calc = (float)123
.
也试过这个-
if($calc == round($calc))
{
die('is integer');
}
else
{
die('is float);
}
但这也不起作用,因为它在每种情况下都会返回'is float'
。在上面的情况下,这不应该是真的,因为 123 在四舍五入后与 123 相同。