What are the potential pitfalls of using is_numeric() to validate numerical input in PHP?

The potential pitfall of using is_numeric() to validate numerical input in PHP is that it can return true for values that are not strictly numeric, such as strings that contain numeric characters or scientific notation. To ensure that the input is strictly numeric, it is better to use is_int() or is_float() depending on the expected data type.

// Validate numerical input using is_int() or is_float() instead of is_numeric()
$input = 123; // Example numerical input

if (is_int($input) || is_float($input)) {
    echo "Input is a valid number.";
} else {
    echo "Input is not a valid number.";
}