Tracks
/
PHP
PHP
/
Syllabus
/
For Loops
Fo

For Loops in PHP

0 exercises

About For Loops

for loops are the most complex type of loop in PHP. They behave like for loops in C, Java, and JavaScript. It's basic form is:

for (expr1; expr2; expr3) {
  // statements
}

The first expression (expr1) is evaluated before the loop starts. The second expression (expr2) is evaluated before each iteration, if it evaluates to a truthy value, the statements are executed. After the executed statements, the third expression (expr3) is evaluated.

Edit via GitHub The link opens in a new window or tab