php tutorial - PHP Do While Loop - php programming - learn php - php code - php script




  • do-while loops are very similar to while loops, except the truth expression is checked at the end of each iteration instead of in the beginning.
  • In PHP do-while is used to provide a control condition.
  • In do-while the block of code executed once and then condition is evaluated. If the condition is true, the statement is repeated as long as the specified condition is true.
 Do While loop

Learn PHP - PHP tutorial - Do While loop - PHP examples - PHP programs

php programming Syntax :

do 
{
    code to be executed;
} 
while (condition is true);
click below button to copy the code. php tutorial - team

php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - php-do-while-loop

learn php Sample Code : a simple php program

<!DOCTYPE html>
<html>
    <head>
        <title>Do-While-Loop</title>
    </head>
    <body>
        <?php
            $a = 1;
            do 
            {
                $a++;
            }
            while( $a < 4 );
            echo ("Loop will be stopped at a = $a" );
        ?>
    </body>
</html>
click below button to copy the code. php tutorial - team

php for beginners Code Explanation :

Code Explanation for Do While Loop In PHP

  1. $a =1 is a variable.
  2. In this example do statement specifies the variable $a which has 1 , that turns out to be true for the condition $a < 4 i.e.( 1<4 ). Therefore, the loop continues.
  3. while($a < 4) specifies the condition lesser than 4 which prints the echo statement “Loop will be stopped at a = 4”.

php tutorials Sample Output :

output for Do While Loop In PHP

  1. Output -> “Loop will be stopped at a = 4“ specifies that the do while loop stopped at 4.


Related Searches to php do while loop

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×