PHP do-while Loop Last Updated : 25 Aug, 2022 Comments Improve Suggest changes Like Article Like Report The do-while loop is very similar to the while loop, the only difference is that the do-while loop checks the expression (condition) at the end of each iteration. In a do-while loop, the loop is executed at least once when the given expression is "false". The first iteration of the loop is executed without checking the condition. Flowchart of the do-while loop: Syntax: do { // Code is executed } while (if the condition is true); Example 1: The following code demonstrates the do..while statement. PHP <?php // Declare a number $num = 10; // do-while Loop do { echo $num . "\n"; $num += 2; } while ($num < 20); ?> Output10 12 14 16 18 Example 2: PHP <?php // Declare a number $num = 0; // do-while Loop do { $num += 5; echo $num . "\n"; } while ($num < 20); ?> Output5 10 15 20 Reference: https://www.php.net/manual/en/control-structures.do.while.php Create Quiz Comment V vkash8574 Follow 0 Improve V vkash8574 Follow 0 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