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.
Thank you for reading. If you would like to stay updated please share and subscribe. 🙂
A1WEBSITEPRO Social Media Pages
Here are my social media pages, lets hook up!