A simple instance of PHP for loop use, Phpfor loop instance
The For loop is used in cases where you know in advance how many times the script needs to run.
Grammar
Parameters:
• Initial value: The primary is to initialize a variable value that sets a counter (but can be any code that is executed once at the beginning of the loop).
• Conditions: cyclic execution of restrictions. If true, the loop continues. If FALSE, the loop ends.
• Increment: used primarily for incrementing the counter (but can be any code executed at the end of the loop).
Note: The above initial and increment parameters can be empty, or there are multiple expressions (separated by commas).
The following example defines a loop with an initial value of I=1. As long as the variable i is less than or equal to 5, the loop continues to run. Each time the loop is run, the variable i increments by 1:
<?php for ($i =1; $i <=5; $i + +) {echo "the number is". $i. "
Output:
The above this PHP for loop use of a simple example is the small part of the whole content to share to everyone, I hope to give you a reference, but also hope that we have a lot of support to help guests home.
http://www.bkjia.com/PHPjc/1133025.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133025.html techarticle a simple instance of the PHP for loop uses a phpfor loop instance for loop that you know beforehand how many times the script needs to run. Syntax for (initial value; condition; increment) {The generation to be executed ...