PHP do…while

Summary: in this tutorial, you will learn how to use the PHP do...while loop statement to execute a code block repeatedly.

Introduction to PHP do…while loop statement #

The PHP do...while statement allows you to execute a code block repeatedly based on a Boolean expression. Here’s the syntax of the PHP do-while statement:

<?php

do {
	statement;
} while (expression);Code language: PHP (php)

Unlike the while statement, PHP evaluates the expression at the end of each iteration. It means that the loop always executes at least once, even the expression is false before the loop enters.

The following flowchart illustrates how the do...while statement works: