Conditional statements allow your PHP code to make decisions based on conditions. PHP supports several ways to control program flow.
if / elseif / else
The most common way to execute code based on a condition.
switch Statement
Used when comparing a single variable against many possible values.
match Expression (PHP 8+)
A newer, cleaner alternative to switch that uses strict comparison and returns a value.
Ternary Operator
A shorthand for simple if/else: $result = condition ? "yes" : "no";
Null Coalescing Operator (??)
Returns the left operand if it exists and is not null: $name = $name ?? "Guest";