Current Location: Home> Function Categories> is_numeric

is_numeric

Detect whether a variable is a numeric or a numeric string
Name:is_numeric
Category:Variable processing
Programming Language:php
One-line Description:Check if the variable is a numeric or a numeric string.

Definition and usage

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.

Example

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

grammar

 is_numeric ( variable ) ;
parameter describe
variable Required. Specifies the variable to check.
Similar Functions
Popular Articles