Control Structures
Control structures are the core of any programming language's control flow logic. They allow your program to make decisions or to repeat an operation. PHP supports several control structures, including:
If, Elseif, Else Statements
These statements are used to perform different actions based on different conditions.
Switch Statement
The switch statement is used to perform different actions based on different conditions:
While Loop
The while loop executes a block of code as long as the specified condition is true:
For Loop
The for loop is used when you know in advance how many times the script should run:
Foreach Loop
The foreach loop works only on arrays, and is used to loop through each key/value pair in an array:
Last updated