gettype()
` function, which returns a string indicating the data type of the variable. is_float()
` function, which returns `true
` if the variable is a float and `false
` otherwise.<?php
$num = 3.14;
if (is_float($num)) {
echo "The variable is a float.";
} else {
echo "The variable is not a float.";
}
?>
The variable is a float.
$num
` is assigned the float value `3.14
`. The `if
` statement checks if `$num
` is a float using the `is_float()
` function. $num
` is a float, then the code inside the `if
` block is executed, which simply prints the message "The variable is a float." Otherwise, the code inside the `else
` block is executed, which prints the message "The variable is not a float."is_float()
` function to check if a variable is a float in PHP.