How can PHP be used to validate user input for whole numbers only?

To validate user input for whole numbers only in PHP, you can use the `filter_var` function with the `FILTER_VALIDATE_INT` filter option. This function will check if the input is a valid integer. You can also use additional conditions or functions to ensure that the input is a whole number.

$user_input = $_POST['user_input'];

if (filter_var($user_input, FILTER_VALIDATE_INT) && $user_input >= 0) {
    // Input is a valid whole number
    echo "Valid whole number input: " . $user_input;
} else {
    // Input is not a valid whole number
    echo "Invalid input. Please enter a whole number.";
}