checking if a number is float in PHP

后端 未结 4 1276
挽巷
挽巷 2020-11-30 14:30

This is really weird. I have this piece of code.

$rewardAmt = $amt;
if(is_float($rewardAmt)){
      print_r(\"is float\");die;
} else {
      print_r(\"is no         


        
4条回答
  •  遥遥无期
    2020-11-30 15:03

    Use filter_var() with FILTER_VALIDATE_FLOAT

    if (filter_var($amount, FILTER_VALIDATE_FLOAT))
    {
         // good
    }
    

提交回复
热议问题