PHP is_numeric() Function
is_numeric() The function is used to check whether a variable is a number or numeric string.
PHP version requirement: PHP 4, PHP 5, PHP 7
Syntax
bool is_numeric ( mixed $var )
Parameter Description:
- $var: the variable to check.
Return Value
If the specified variable is a number or numeric string, returns TRUE; otherwise returns FALSE. Note that float returns 1, i.e., TRUE.
Example
Example
The output is:
678 是数字
a678 不是数字
---------------------
bool(true)
[ 678 是数字吗? ]
---------------------
bool(false)
[ runoob.com 是数字吗? ]
---------------------
bool(true)
[ 698.99 是数字吗? ]
---------------------
bool(false)
[ Array 是数字吗? ]
---------------------
bool(true)
[ 125689.66 是数字吗? ]
Available PHP Functions