I have this
$number = 0.5
if (is_float($number))
{
echo 'float';
}
else
{
echo 'not float';
}
and it echos not float.
what could be the reason
thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Probably
$numberis actually a string:"0.5".See
is_numericinstead. Theis_*family checks against the actual type of the variable. If you only what to know if the variable is a number, regardless of whether it’s actually anint, afloator astring, useis_numeric.If you need it to have a non-zero decimal part, you can do: