After the proper explanation and operation of the FOR loop, both in javascript and PHP (to highlight the similarity of the two), see at the end of this answer, your commented code and running passo a passo
in the ideone.
The for statement creates a loop consisting of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement or a sequence of statements executed in sequence.
for ([inicialização]; [condição]; [expressão final])
initialization
An expression (including attribution expressions) or variable declarations. Generally used to start the variable counter. This expression can optionally declare new variables with the keyword var. These variables are non-local in the loop, that is, they are in the same scope as the for loop is. The result of this expression is discarded.
condition
An expression to evaluate before each iteration of the loop. If this expression evaluates to true, statement will be executed. This condition test is optional. If omitted, the condition will always be evaluated as true. If the expression evaluates to false, the execution will go to the first expression after the for loop construct.
final expression
An expression that will be evaluated at the end of each loop iteration. This occurs before the next assessment of the condition. Usually used to update or increment the counter variable.
statement
A statement that is executed while the condition is true. To execute multiple conditions within the loop, use a block statement ({...}) to group these conditions together. To not execute statements within the loop, use an empty statement (;).
Usage examples
The statement is started by declaring the variable i and initializing it to 0. It checks if i is less than nine, executes the two subsequent statements, and increments 1 to the variable i after each passing through the loop.
for (var i = 0; i < 9; i++) {
console.log(i);
}
All three expressions in the for loop condition are optional.
For example, in the boot block, it is not necessary to initialize variables:
var i = 0;
for (; i < 9; i++) {
console.log(i);
}
As with the boot block, the condition is also optional. If you are omitting this expression, you should make sure to break the loop in the body so as not to create an infinite loop.
for (var i = 0;; i++) {
console.log(i);
if (i > 3) break;
}
You can also omit all three blocks. Again, be sure to use a break statement at the end of the loop and also modify (increment) a variable, so that the break condition is true at some point.
var i = 0;
for (;;) {
if (i > 3) break;
console.log(i);
i++;
}
SOURCE
With PHP It's pretty similar, see
Usage examples
The statement is started by declaring the variable i and initializing it to 0. It checks if i is less than nine, executes the two subsequent statements, and increments 1 to the variable i after each passing through the loop.
In this first example we have our common FOR, as we all learn:
<?php
for($i = 0; $i < 5; $i++)
{
echo $i;
echo '<br />';
}
In this second example, we remove the first parameter from FOR, and leave the variable $ i set outside the loop:
<?php
$i = 0;
for(; $i < 5; $i++)
{
echo $i;
echo '<br />';
}
Now, let's take the third parameter, and increment the variable inside the loop.
<?php
$i = 0;
for(; $i < 5;)
{
echo $i;
echo '<br />';
$i++;
}
Finally, we will remove the second parameter.
<?php
$i = 0;
for(; ; )
{
echo $i;
echo '<br />';
if($i == 5)
{
break;
}
$i++;
}
Want to see it to believe it? São Tomé test on ideone
Notice that in all these examples above, we escape the infinite Loop with some condition or mechanism that we put inside the loop. Be careful. This last example if nothing is done inside the loop, easily generates an infinite loop.
Your commented code
$a = true;
$b = -2;
$c = 7;
$condicao="";
//realiza uma iteração FOR toda vez que $b for menor que $c ou $a for true
//retiramos o primeiro parâmetro do FOR, a variável $b já foi definida fora do laço
for ( ; $b < $c || $a; $b++){
if ($c + $b * 2 > 20)
// quando a condição acima for verdadeira, $a se torna false
$a = false;
//e a condição FOR já não será mais verdadeira, isto é, zefini, ou seja, "c'est fini"
echo $b." ";
}
Follow step-by-step instructions for your code at IDEONE