is_float
Detect whether the variable is floating point
is_float()
function checks whether the variable is of type float.
If the variable's type is float, the function returns true
(1), otherwise false
.
Check whether the variable is float type:
<?php $a = 32 ; echo "a is " . is_float ( $a ) . "<br>" ; $b = 0 ; echo "b is " . is_float ( $b ) . "<br>" ; $c = 32.5 ; echo "c is " . is_float ( $c ) . "<br>" ; $d = "32" ; echo "d is " . is_float ( $d ) . "<br>" ; $e = true ; echo "e is " . is_float ( $e ) . "<br>" ; $f = "null" ; echo "f is " . is_float ( $f ) . "<br>" ; $g = 1.e3 ; echo "g is " . is_float ( $g ) . "<br>" ; ?>
Try it yourself
Note that even if the variable g
is represented using scientific notation, it is still considered float type, so is_float($g)
returns TRUE
.
is_float ( variable ) ;
parameter | describe |
---|---|
variable | Required. Specifies the variable to check. |