Skip to main content

Posts

Showing posts with the label for statement

PHP FOR STATEMENT

FOR The for function is the more complex sibling of the while function and provides a more streamline and  complex looping mechanism.  The for function takes three expressions; the first expression is evaluated  by default at the first iteration of the loop, the second expression is evaluated at the beginning of each  iteration (and determines if the loop will continue) and the third expression is evaluated at the conclusion of  each loop.  Any of the expressions can be empty and the logic that would take place in the expression can  be substituted in the body of the function itself.  The statement list within the for code body can consist of  one or more statements.  for (expression1; expression2; expression3)  {      -- statements that execute while the expressions evaluates false  }  The following examples demonstrate how the for iterative control statement can work:  <?php      for ($ctemp = 0; $ctemp <= 20; $ctemp = $ctemp + 1) {          $ftemp = 32 + $ctem