PHP check if variable is a whole number

后端 未结 20 1167
感动是毒
感动是毒 2020-12-29 20:05

I have this PHP code:

$entityElementCount = (-($highScore-$totalKeywordCount))/0.29;

What i want to know is, how to check whether $

20条回答
  •  暖寄归人
    2020-12-29 20:25

        $num = 2.0000000000001;
        if( $num == floor( $num  ) ){
            echo('whole');
        }else{
            echo('fraction');
        }
    

    EX:

    2.0000000000001 | fraction

    2.1 | fraction

    2.00 | whole

    2 | whole

提交回复
热议问题