Probably $number is actually a string: "0.5" .
See is_numeric . The is_* family checks the actual type of a variable. If you only know if the variable is a number, whether it is int , a float or string , use is_numeric .
If you need to have a nonzero decimal part, you can do:
//if we already know $number is numeric... if ((int) $number == $number) { //is an integer }
Artefacto
source share