In the process of developing the software, there are some times that need to flexibly apply the various forms of the For statement, now the other forms of the For statement, in the form of example code to list out!
The first change, extract the first part of the For-loop syntax
$i = 1;
for (; $i <2; $i + +) {//The first semicolon cannot be omitted
echo "This is the first". $i. " Secondary output!
";
}
?>
The second change, the first part of the For loop syntax is extracted, and the third part of the increment is placed in the For loop body
$i = 1;
for (; $i <2;) {//The first semicolon cannot be omitted
echo "This is the first". $i. " Secondary output!
";
$i + +;
}
?>
The third change, omitting all of the for-loop syntax
$i = 1;
for (;;) {//The first semicolon cannot be omitted
if ($i >1)
Break
echo "This is the first". $i. " Secondary output!
";
$i + +;
}
?>
All programs in Apache 2.2+php5.2.6 Pass!
Poor then change, the general rule Tatsu, it appears in the program also has such a philosophy!
Excerpt from CHUOYUE05 's column
http://www.bkjia.com/PHPjc/478247.html www.bkjia.com true http://www.bkjia.com/PHPjc/478247.html techarticle in the process of developing the software, there are times when it is necessary to flexibly apply the various forms of the For statement, and now the other forms of the For statement are listed in the way of example code!//First change, put for loop syntax ...