What are the potential pitfalls of using is_numeric for input validation in PHP?

Using is_numeric for input validation in PHP can be problematic because it only checks if a value is numeric or not, without considering other types of input that may be valid. This can lead to unexpected behavior if the input is not strictly numeric, such as when dealing with strings that represent numbers or other types of data. To address this issue, it's better to use more specific validation functions or filters tailored to the type of input expected.

// Example of using filter_var with FILTER_VALIDATE_INT for integer input validation
$input = "123";
if (filter_var($input, FILTER_VALIDATE_INT) !== false) {
    echo "Input is a valid integer.";
} else {
    echo "Input is not a valid integer.";
}