The do...while Statementdo { statement } while (expr); The PHP do...while loop is very similar to the while loop, except that expr is checked at the end of each iteration instead of at the beginning. Thus, compared to standard while loops, the first iteration of a do...while loop will always run, which is not necessarily true for a while loop (because it depends on the while loop's expression). Here's an example of using a while loop where the loop condition is false from the very beginning, so this script doesn't echo anything: <?php $value =10; while ($value < 5){ $value += 2; echo $value, "<BR>"; } ?> However, in a do...while loop, the condition is tested at the end, so this script does echo 12 in a browser: <?php $value = 10; do{ echo $value, "<BR>"; $value += 2; } while ($value < 5); ?> |