What Is a Control Structure?
In simple terms, a control structure allows you to control the flow of code execution in your application. Generally, a program is executed sequentially, line by line, and a control structure allows you to alter that flow, usually depending on certain conditions.
Control structures are core features of the PHP language that allow your script to respond differently to different inputs or situations. This could allow your script to give different responses based on user input, file contents, or some other data.
- Conditional statement is used for making condition based program.
- Conditional Statements allow you to branch the path of execution in a script based on whether a single, or multiple conditions.
- If- Else
- Nested If- Else
1. If :- if x and then do y (if condition is true then print some statement).
2. If- Else :- If x and then do y otherwise do Z ( if condition is true then print some statement and otherwise print some different statement).
3. Nested If-else:- More than one condition is used.
4. Switch Case:- Use the switch statement to select one of many blocks of code to be execute.