/* The main difference between both loops is that while loop checks the condition at the beginning, whereas do-while loop checks the condition at the end of the loop */
// make the while loop example
$i = 1;
while ($i < 5) {
    echo "the result is $i", "\n";
    $i++;
    }
// please note, If the condition never becomes false, the statement will continue to execute indefinitely.
// make the do...while loop
$i = 1;
do {
echo "hello world";
}
while ($i < 0);
// is that case will return the result?
/* Note that in a do while loop, the condition is tested AFTER executing the statements within the loop. This means that the do while loop would execute its statements AT LEAST ONCE, EVEN IF THE CONDITION IS FALSE the first time */ // Therefore it returns "hello world" only one time
by Luka Khitaridze
2 years ago
PHP
LOOPS
0
Pro tip: use ```triple backticks around text``` to write in code fences