PHP Check if Input is Number: is_numeric() Guide

In PHP, you can use the built-in is_numeric() function to check if the input value is a number. This function is used to verify if a variable is a number or a numeric string. Here is an example:

$input = "123";
if (is_numeric($input)) {
    echo "输入是一个数字";
} else {
    echo "输入不是一个数字";
}

In the example above, if the value of $input is a number or a numerical string, output “Input is a number”; otherwise, output “Input is not a number”.

bannerAds