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.