In programming, a problem specific to decision making and the flow of execution can be broken down into three specific types of control structures. These are:
- Sequential Execution
- Loops (while, do/while, for, etc.)
- Two-Way Decisions (if, if/else, switch, etc.)
The most commonly used conditional statement is the if/else statement.
if ($expression)
{
// statement
}
else
{
// statement
}
It is important to remember a few things about this statement:
- The else clause is optional
- Best use is to make the expression boolean logic, evaluating to either True or False