How can PHP be used to display error messages for invalid form input, such as numbers outside of the range 0-9?

When validating form input in PHP, you can use conditional statements to check if the input falls within the desired range. If the input is outside of the range, you can display an error message to the user. To do this, you can use an if statement to check if the input is not between 0 and 9, and then use the echo function to display the error message.

$input = $_POST['number'];

if ($input < 0 || $input > 9) {
    echo "Error: Please enter a number between 0 and 9.";
}