If/Else Example

The variable $number is set to: 7

We are checking if $number is greater than 10.

Result: 7 is NOT greater than 10, so the ELSE block runs.


Switch (Case) Example

The variable $day is set to: Monday

The switch statement compares this value to different cases.

Matched case 'Monday': This means it is the start of the week.


Conditions allow a program to make decisions by checking values and choosing what code should run next. An if/else statement evaluates a true or false expression and executes different blocks depending on the outcome. A switch statement compares one variable to multiple possible values, which is useful when there are many specific cases to handle.