Conditions

Example 1 — If and else

Score: 85 Decision: Passed

Example 2 — Switch and case

Topic: math Decision: Study PHP arithmetic operators.

Explanation

Conditions let a program choose which instructions to execute. An if statement evaluates an expression and runs its block when the result is true; else handles the false outcome. A switch compares a value with case labels. Break prevents execution from continuing into the next case, while default handles values that match none of the listed cases.

Return to Activity 3 index