All the conditional statements and loop statements are collectively termed as Control Statements.
Conditional statements are used in a code to perform an action only if a particular condition is satisfied.
PHP provides four types of conditional statements. These are:
If statement is used to perform an action if a single condition is true.
If else statement is used to perform an action if a single condition is true and to perform another action if that condition is false.
If elseif else statement is used to perform different actions for different conditions.
Switch statement is used to select one of the action to perform from multiple actions, relative to the true condition.
Loop Statements are used to execute a block of code continuously as long as the condition of the loop is true, and stops only when the condition fails.
PHP provides three types of loop statements. These are:
For loop is used to execute a group of action only for a specified number of times.
While loop is used to execute a group of action as long as the specified condition is true.
Do While Loop:
Do While loop is used to execute a block of code at least once and then to repeat the actions as long as the specified condition is true.