PHP 8 Beginner Basics · 1 min read

do...while loop

Start the PHP 8 learning path »

❮ PHP 8 Home All Tutorials ❯

How do I run a loop at least once?

do...while.

Example

PHP 8 Example
<?php
$i = 0;
do {
  echo $i;
  $i++;
} while ($i < 1);

Line-by-Line Walkthrough

Body runs before the condition is checked.

Need more coins?

You do not have enough coins for this action.

Your balance: 0 coins

Share

Reactions

Loading reactions…