Double? Integer? — PHP

后端 未结 2 1127
滥情空心
滥情空心 2021-01-29 11:50

The following code generates two random decimal values, then subtracts them to get $c.

$a = mt_rand(5, 75);
$b = mt_rand(5, 75);
$adjuster = mt_rand         


        
2条回答
  •  闹比i
    闹比i (楼主)
    2021-01-29 12:41

    Do something like this to see if $c is a whole number (possibly stored as a double):

    if(intval($c) == $c) {
        echo "I'm a whole number";
    }
    

    See here: http://3v4l.org/ubPK4

提交回复
热议问题