Key Concepts

Review core concepts you need to learn to master this subject

PHP Nested Conditionals

$num = 5; // nested conditional if ($num > 0){ echo 'The number is positive. <br>'; if ($num % 2 === 0){ echo 'The number is even.'; } } else { echo 'The number is negative.'; }

In PHP, nested conditional statements deepen the complexity of our programs’ decision-making capabilities. They allow us to create programs where each decision made sends our program on a different route where it might encounter additional decisions.

Logical Operators and Compound Conditions
Lesson 1 of 1
  1. 1
    In the previous lesson, we explored the foundations of making decisions in programming: booleans and conditionals. In this lesson, we’ll deepen the complexity of our programs’ decision-making capab…
  2. 2
    Expressions that use logical operators evaluate to boolean values. The logical operator || takes two different boolean values or expressions as its operands and returns a single boolean value. …
  3. 3
    Often, we’ll encounter situations where we have more than one condition we need satisfied in order to take an action. The logical && operator returns TRUE only if both of its operands evaluat…
  4. 4
    The logical not operator (!) takes only a right operand. It reverses the boolean value of its operand. !TRUE; // Evaluates to: FALSE !FALSE; // Evaluates to: TRUE The not operator has very …
  5. 5
    The logical operator xor stands for exclusive or. It takes two different boolean values or expressions as its operands and returns a single boolean value. Unlike regular or which evaluates to TRU…
  6. 6
    An alternate syntax for logical || operator is the or operator, and an alternate syntax for logical && operator is the and operator. These operators have the advantage of making our code more human…
  7. 7
    Separation of concerns is the programming design principle of organizing code into distinct sections each handling a specific task. It enables us to quickly navigate our code and know where to look…
  8. 8
    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 br…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo