How can an input field in PHP be restricted to only accept integer values?

To restrict an input field in PHP to only accept integer values, you can use the `filter_var` function with the `FILTER_VALIDATE_INT` filter. This function will validate the input and only allow integer values to be passed through. If the input is not an integer, it will return false.

$input = $_POST['input_field'];

if (filter_var($input, FILTER_VALIDATE_INT) !== false) {
    // Input is a valid integer
    // Proceed with your code here
} else {
    // Input is not a valid integer
    // Handle the error or display a message to the user
}