Home >Backend Development >PHP Tutorial >PHP coding standards (15)_PHP tutorial
6.5 for statement
A for statement should have the following format:
for (initialization; condition; update) {
statements;
}
An empty for statement (all work is done in initialization, conditional judgment, update clause) should have the following format:
for (initialization; condition; update);
When using commas in the initialization or update clause of a for statement, avoid the increased complexity caused by using more than three variables. If necessary, you can use separate statements before the for loop (for the initialization clause) or at the end of the for loop (for the update clause).
6.6 while statement
A while statement should have the following format
while (condition) {
statements;
}
An empty while statement should have the following format:
while (condition) ;
6.7 do...while statement
A do-while statement should have the following format:
do {
statements;
} while (condition);