Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP is_numeric() Function

PHP is_numeric() Function

PHP Available FunctionsAvailable PHP Functions

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:

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 是数字吗? ]

PHP Available FunctionsAvailable PHP Functions