While loop in PHP

PHP while Loop
  • The while loop is used through a block of code as long as the specified condition is true.
  • The while loop executes a block of code as long as the specified condition is true.
  • Syntax
  • while (condition is true) {
    code to be executed;
    }



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