0PricingLogin
PHP Academy · Lesson

if, elseif, and else

Make decisions in PHP with conditional branching.

Conditional Logic in PHP

Conditional statements let your program make decisions. PHP provides if, elseif, and else for branching logic.

The condition inside if () is evaluated as a boolean — truthy proceeds into the block, falsy skips it.

Basic if Statement

The simplest conditional — run code only when a condition is true:

<?php
$age = 20;

if ($age >= 18) {
    echo 'Adult';
}
// Output: Adult

All lessons in this course

  1. if, elseif, and else
  2. Switch and Match Statements
  3. for and while Loops
  4. foreach and Loop Control
← Back to PHP Academy