if / elseif / else
Try it yourself →Executes code based on a condition.
Syntax
if (condition) { } elseif (condition) { } else { }Description
Condition in parentheses, blocks in { }. Use == for equality or === for strict type checking.
Example
<?php
$score = 75;
if ($score >= 50) {
echo "Passed";
} else {
echo "Failed";
}Expected output
Passed
When to use?
Flow branching, checks.