PHP while Loop Last Updated : 22 Aug, 2022 Comments Improve Suggest changes 1 Likes Like Report The while loop is the simple loop that executes nested statements repeatedly while the expression value is true. The expression is checked every time at the beginning of the loop, and if the expression evaluates to true then the loop is executed otherwise loop is terminated. Flowchart of While Loop: Syntax: while (if the condition is true) { // Code is executed } Example 1: This example uses a while loop to display numbers. PHP <?php // Declare a number $num = 10; // While Loop while ($num < 20) { echo $num . "\n"; $num += 2; } ?> Output10 12 14 16 18 while-endWhile loop: Syntax: while (if the condition is true): // Code is executed ... endwhile; Example 2: This example uses while and endwhile to display the numbers. PHP <?php // Declare a number $num = 10; // While Loop while ($num < 20): echo $num . "\n"; $num += 2; endwhile; ?> Output10 12 14 16 18 Reference: https://www.php.net/manual/en/control-structures.while.php Create Quiz Comment V vkash8574 Follow 1 Improve V vkash8574 Follow 1 Improve Article Tags : Web Technologies PHP PHP-basics Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like