Google News
logo
PHP Program to Validate an integer that is 0
To validate an integer that is 0 in PHP, we can use the `filter_var()` function with the `FILTER_VALIDATE_INT` filter.

Here's an example PHP program to validate an integer that is 0 :
Program :
<?php
$number = 0;

if (filter_var($number, FILTER_VALIDATE_INT) !== false) {
    echo "The number is a valid integer.";
} else {
    echo "The number is not a valid integer.";
}
?>
Output :
The number is a valid integer.
In this program, we first initialize a variable `$number` with the value `0`. We then use the `filter_var()` function with the `FILTER_VALIDATE_INT` filter to validate this variable as an integer.

If the validation succeeds, we output a message saying that the number is a valid integer. If the validation fails, we output a message saying that the number is not a valid integer.