The following expressions are equivalent:
<?php
// setting true
$flag = true;
$flag = True;
$flag = TRUE;
$flag = 1==1;
// setting false
$flag = false;
$flag = False;
$flag = FALSE;
$flag = 1==2;
?>
The moral of the story is that boolean operators return a boolean value, i.e., "1==1" returns a boolean value of true. Someone who is not aware of this may write a block of code such as:
<?php
// even number?
$num = 10;
if($num % 2 == 0){
$isEven = true;
}
else{
$isEven = false;
}
?>
when all that is needed is:
<?php
$num = 10;
$isEven = $num % 2 == 0;
?>
Other examples, for illustrative purposes:
<?php
// two numbers
$a = 2;
$b = 3;
$aBiggerThanB = 2 > 3; // $aBiggerThanB is set to false
// lower case vowel check (corrected)
$c = "u";
$isVowel = $c == "a"|| $c == "e"|| $c == "i"|| $c == "o"|| $c == "u";
?>