<?php
$sum10 = 0;
for ($i = 1; $i <= 10; $i++) {
$sum10 += $i;
}
//sum10 is 55
echo $sum10;
| for (expr1; expr2; expr3) statement The first expression (expr1) is evaluated (executed) once unconditionally at the beginning of the loop. In the beginning of each iteration, expr2 is evaluated. If it evaluates to true, the loop continues and the nested statement(s) are executed. If it evaluates to false, the execution of the loop ends. At the end of each iteration, expr3 is evaluated (executed). |