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 Comment More info V vkash8574 Follow Improve Article Tags : Web Technologies PHP PHP-basics Explore PHP Tutorial 8 min read BasicsPHP Syntax 4 min read PHP Variables 5 min read PHP | Functions 8 min read PHP Loops 4 min read ArrayPHP Arrays 5 min read PHP Associative Arrays 4 min read Multidimensional arrays in PHP 5 min read Sorting Arrays in PHP 4 min read OOPs & InterfacesPHP Classes 2 min read PHP | Constructors and Destructors 5 min read PHP Access Modifiers 4 min read Multiple Inheritance in PHP 4 min read MySQL DatabasePHP | MySQL Database Introduction 4 min read PHP Database connection 2 min read PHP | MySQL ( Creating Database ) 3 min read PHP | MySQL ( Creating Table ) 3 min read PHP AdvancePHP Superglobals 6 min read PHP | Regular Expressions 12 min read PHP Form Handling 4 min read PHP File Handling 4 min read PHP | Uploading File 3 min read PHP Cookies 9 min read PHP | Sessions 7 min read Like