Learn
Logical Operators and Compound Conditions
Review
Great job! You’ve learned the tools needed to craft programs with powerful decision making capabilities. Let’s review what we covered:
- By nesting conditionals within one another, we can create branching decisions.
- The logical operator
||
takes two different boolean values or expressions as its operands and returns a single boolean value. It returnsTRUE
if either its left operand or its right operand evaluate toTRUE
. - The logical
&&
operator returnsTRUE
only if both of its operands evaluate toTRUE
. It returnsFALSE
if either or both of its operands evaluate toFALSE
. - The logical not operator (
!
) takes only a right operand. It reverses the boolean value of its operand. - The logical exclusive or operator (
xor
) returnsTRUE
only if either its left operand or its right operand evaluate toTRUE
, but not both or neither. - PHP includes alternate syntax for the
||
and&&
operators: we can useor
in place of||
, and we can useand
in place of&&
. These operators work much the same way but have different operator precedence. - We can include code from one file inside another with
include
which allows us to write mode modular programs.
Awesome work!