Checking if a Variable is an Integer or Float in PHP


Determine if a variable is an integer or float.

Source Code

$num = 10.5;
if (is_int($num)) {
    echo "$num is an integer";
} elseif (is_float($num)) {
    echo "$num is a float";
} else {
    echo "$num is not an integer or float";
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments