Do while loop in PHP

PHP do while Loop
  • The do...while loop is used through a block of code once, and then repeats the loop as long as the specified condition is true.
  • The do...while loop will always execute the block of code once, it will then check the condition, and repeat the loop while the specified condition is true.
  • Syntax
  • do {
    code to be executed;
    } while (condition is true);



  • example
  • <!DOCTYPE html>
    <html>
    <body>
    <?php
    
    $a = 1;
    do {
    echo "number: $a </br>";
    $a++;
    } while ($a <= 5);
    ?>
    
    </body>
    </html>