Bifalgorithm post · Computer science one · Do-While Loops

How does a do-while loop differ from a while loop in PHP?

How does a do-while loop differ from a while loop in PHP? (Computer science one · Do-While Loops) — "39.3. Do-While Loops\n\nPHP also supports do-while loops.…

Ideas in this flowchart

  • Do-while loops in PHP
  • PHP supports do-while loops.
  • The key difference from a while loop is when the continuation condition is checked.
  • A while loop checks the condition before the loop body begins.
  • A do-while loop checks the condition at the end of the loop.
  • A do-while loop always executes at least once.
  • Do-while syntax conventions
  • The opening curly bracket appears on the same line as the do keyword.
  • The while keyword and continuation condition appear on the same line as the closing curly bracket.
  • A semicolon appears at the end of the continuation condition.
  • Code Sample 39.4 demonstrates a do-while loop in PHP.
  • The example initializes i, performs an action, increments i, and continues while i is less than or equal to 10.
Feed/

How does a do-while loop differ from a while loop in PHP?

No cover

Channel

Computer science one

1 page

"39.3. Do-While Loops\n\nPHP also supports do-while loops. Recall that the difference between a while loop and a do-while loop is when the continuation condition is checked. For a while loop it is prior to the beginning of the loop body and in a do-while loop it is at the end of the loop. This means that a do-while always executes at least once. An example can be found in Code Sample 39.4.\n\nThe opening curly bracket is again on the same line as the keyword do. The while keyword and continuation condition are on the same line as the closing curly bracket. In a slight departure from previous syntax, a semicolon does appear at the end of the continuation condition even though it is not an executable statement.\n\nCode Sample 39.4.: Do-While Loop in PHP\n\n$i;\n\ndo {\n\n//perform some action\n\n$i++;\n\n} while($i <= 10);"

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.