PHP 8 Beginner Basics · 1 min read

while loop

Start the PHP 8 learning path »

❮ PHP 8 Home All Tutorials ❯

How do I loop while a condition is true?

while.

Example

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

Line-by-Line Walkthrough

Ensure the condition eventually becomes false.

Need more coins?

You do not have enough coins for this action.

Your balance: 0 coins

Share

Reactions

Loading reactions…