Definition: The is_numeric () function is used to check if a value is a number. This could be used within an if () statement to treat numbers in one way and non-numbers in another. It will return true or false. Numeric strings consist of an optional sign (such as + or -), any number of digits, optional decimal point and optional exponent. It will also identify a hexadecimal number, but only on its own without a sign, decimal or exponent.
Also Known As: Is Numeric, Is Number
Examples:
<?php
if (is_numeric (887))
{
echo "Yes";
} else {
echo "No";
}
?>
Since 887 is a number, this should echo "Yes"
<?php
if (is_numeric ("cake"))
{
echo "Yes";
} else {
echo "No";
}
?>
Since cake is not a number, this should echo "No"



