Boolean Constants
true
and false
are the only two Boolean values treated as constants. A simple Boolean value can be a simple expression like the following:
if (true) { echo "I love programming."; } else { echo "I hate programming."; }
If the statement within parentheses results in true
, then the true
block should be executed; otherwise, the false
block should.
Alternatively, we could write the following expression:
if (false) { echo "I hate programming."; } else { echo "I love programming."; }
Both approaches output I love programming.
.
In the preceding examples, we used the if…else
control statement, which we are going to discuss a little later in this chapter.