What are the potential pitfalls of using filter_var with FILTER_VALIDATE_INT in PHP?

When using filter_var with FILTER_VALIDATE_INT in PHP, one potential pitfall is that it may not handle certain edge cases correctly, such as negative numbers or numbers in scientific notation. To solve this issue, it is recommended to use the intval() function in combination with filter_var to ensure accurate integer validation.

$input = "-123";
$filtered_input = filter_var($input, FILTER_VALIDATE_INT) !== false ? intval($input) : null;

if ($filtered_input !== null) {
    // Integer value is valid
    echo "Valid integer: " . $filtered_input;
} else {
    // Integer value is not valid
    echo "Invalid integer input";
}