What is a loop in PHP
Example of a For loop
This for loop contains 10 lines with the content:
This is the row number: + (consecutive row number => is the result of the incremented variable $ i)
issued among each other.
The For loop in detail
Here a variable $ i with the value 1 is created ($ i = 1;).
The loop starts with the start value $ i = 1.
The condition for executing the loop is now formulated. $ i <= 10;
The loop continues as long as the value of the variable $ i is less than or equal to the value 10.
Finally, the change behavior of the counter variable is determined. With $ i ++ the variable $ i is increased by the value "one" after each loop pass.
In practice, the variable $ i defines the number of loop iterations.
Initially, $ i receives the value 1, and a subsequent flow condition checks whether the variable value is less than or equal to 10. As long as this condition is true, the loop is executed. Finally, the variable is incremented by 1 in the loop head.
In the body of the loop, an echo command is used to output a text that contains the value of the incremented variable at the end.
It is important that the individual statements in the loop head are separated from one another by a semicolon. In the case of multi-line instructions, the instructions must be enclosed in curly brackets in the body. In the case of single-line instructions, however, this is not absolutely necessary.
- What does Buddha think of souls
- How do I add refreshment on resume
- How to use Peloton
- What is meant by alleles
- How can I quietly commit suicide?
- What is an ACPI Compatible Embedded Controller
- Does a Wix site affect your SEO?
- What do previous JEE toppers do
- Where were you two nights ago
- Why have fugues fallen out of favor
- What wine do rich people drink
- Why is high ISO grainy
- Which pants go with a white shirt
- Why is my AirDrop not working
- How are cards made during great wars
- What is the real meaning of pi
- What confuses new parents
- India will drop the dollar
- Why does Kejriwal accuse Anil Ambani
- What was your favorite instrument for studying
- Who invented satellite communication
- Care for your child's adult teeth
- Which amendment justified federalism and how
- How do I get a nice friend