Checking for Inequality in PHP
There is also the operator !=, which,
on the contrary, checks for inequality. Let's
check, for example, that the test variable
is not equal to 0:
<?php
$test = 1; // let the variable value be 1
if ($test != 0) {
echo '+++'; // this will work because the variable is NOT equal to 0
} else {
echo '---';
}
?>
Let's change the variable value:
<?php
$test = 0; // let the variable value be 0
if ($test != 0) {
echo '+++';
} else {
echo '---'; // this will work because the variable is equal to 0
}
?>
Check that the variable $test
is not equal to 10.