Equality Check in PHP
To check two values for equality, the
operator == is used. Let's check for example,
that the variable $test is equal to 0:
<?php
$test = 0; // let the variable value be 0
if ($test == 0) {
echo '+++'; // this will work, because the variable is equal to 0
} else {
echo '---';
}
?>
Let's change the value of the variable so that the condition is not met:
<?php
$test = 1; // let the variable value be 1
if ($test == 0) {
echo '+++';
} else {
echo '---'; // this will work, because the variable is NOT equal to 0
}
?>
Check that the variable $test
is equal to 10.