PHP check if variable is a whole number

后端 未结 20 1153
感动是毒
感动是毒 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:37

    A simple solution for positive whole numbers only. This may not work for everything.

    $string = '0x539';
    $ceil = ceil($string);
    
    if($ceil < 1){
      $ceil = FALSE; // or whatever you want i.e 0 or 1
    }
    
    echo $ceil; // 1337
    

    You can use floor() instead of ceil() if so desired.

提交回复
热议问题