The `
for
` loop is a type of loop statement in PHP that allows you to execute a block of code repeatedly for a specified number of times.
The basic syntax of a `
for
` loop in PHP is as follows :
for (initialization; condition; increment/decrement) {
// code to execute for each iteration
}​
In this syntax, `
initialization
` is an expression that is executed once before the loop starts, `
condition
` is an expression that is evaluated before each iteration of the loop, and `
increment/decrement
` is an expression that is executed after each iteration of the loop.
If `
condition
` is true, then the code inside the loop is executed. After the code inside the loop is executed, the `
increment/decrement
` expression is executed, and the loop continues as long as `
condition
` is true.
Here's an example of a PHP program that uses a `
for
` loop to print the numbers from
1 to 10 :