July 25, 2017

Core PHP: The For Loop (5.8)

The for Loop


The for loop is used when you know in advance how many times the script should run.
for (init; test; increment) {
   code to be executed;
}

Parameters:
init: Initialize the loop counter value
test: Evaluates each time the loop is iterated, continuing if evaluates to true, and ending if it evaluates to false
increment: Increases the loop counter value
Each of the parameter expressions can be empty or contain multiple expressions that are separated with commas.
In the for statement, the parameters are separated with semicolons.

No comments:

Post a Comment