Concept Flow - If-else execution flow
Start
Evaluate condition
Execute if-block
End
Execute else-block
End
The program checks a condition. If true, it runs the if-block. Otherwise, it runs the else-block. Then it ends.
<?php $age = 18; if ($age >= 18) { echo "Adult"; } else { echo "Minor"; } ?>
| Step | Condition ($age >= 18) | Result | Branch Taken | Output |
|---|---|---|---|---|
| 1 | 18 >= 18 | True | if-block | Adult |
| 2 | End of if-else | - | - | - |
| Variable | Start | After Step 1 | Final |
|---|---|---|---|
| $age | 18 | 18 | 18 |
if (condition) {
// code if true
} else {
// code if false
}
Checks condition once.
Runs if-block if true.
Runs else-block if false.