is_numeric
Detect whether a variable is a numeric or a numeric string
The is_numeric()
function is used to check whether a variable is a numeric string or a numeric string.
If the variable is a numeric or numeric string, this function returns true
(1), otherwise false
/ no return value.
Check if the variable is a numeric or a numeric string:
<?php $a = 32 ; echo "a is " . is_numeric ( $a ) . "<br>" ; $b = 0 ; echo "b is " . is_numeric ( $b ) . "<br>" ; $c = 32.5 ; echo "c is " . is_numeric ( $c ) . "<br>" ; $d = "32" ; echo "d is " . is_numeric ( $d ) . "<br>" ; $e = true ; echo "e is " . is_numeric ( $e ) . "<br>" ; $f = null ; echo "f is " . is_numeric ( $f ) . "<br>" ; ?>
Try it yourself
is_numeric ( variable ) ;
parameter | describe |
---|---|
variable | Required. Specifies the variable to check. |