Php 7 While Loop Repeat Different Information Dynamically | Lesson 19

Compare While Loop And Do While Loop

If we were to compare the “while loop” with the “do while loop” you might be thinking that they are doing the same thing. Consider these 2 code examples.

Do While Loop

In this example of the “do while loop” the conditional statement is less than or equal to zero. However, when you run the statement you will still get a result.

$var=1;
do{
echo ' The loops says '.$var;
$var++; }while($var <= 0 );

While Loop Alone

If we use the “while loop alone” in the same manor we will not get any result. The conditional statement is once again set to zero in this example.

$var=1;
while($var <= 0 ){
echo 'The loop says '.$var;
$var++;
}

When running this code example you will notice that you do not get any result whatsoever.

Only cool people share!

Thank you for reading. If you would like to stay updated please share and subscribe. 🙂

 

Php 7 While Loop Repeat Different Information Dynamically | Lesson 19 was last modified: October 29th, 2021 by Maximus Mccullough
Php 7 While Loop Repeat Different Information Dynamically

Pages:Previous 1 2

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.