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

To validate user input for whole numbers in PHP, you can use the `filter_var()` function with the `FILTER_VALIDATE_INT` filter. This function will check if the input is a valid integer. If the input is not a whole number, it will return false.

$user_input = $_POST['user_input'];

if (filter_var($user_input, FILTER_VALIDATE_INT) === false) {
    echo "Please enter a valid whole number.";
} else {
    echo "Input is a valid whole number.";
}