conditions.php

If / Else example

You are an adult.

Switch / Case example

The color is red.

Explanation

Conditions let your program make decisions for you in a way. An if/else checks whether something is true, and then runs one block of code or another depending on what the outcome might be. A switch compares one value to many possible cases and runs the matching one. This is how programs respond differently in different situations.

Back