why Hello will be printed once in this case. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why Hello will be printed once in this case.

$i = 1; do { echo "Hello"; } while($i < 0);

27th May 2019, 12:48 PM
Krishnadev Thakur
Krishnadev Thakur - avatar
2 Answers
+ 1
Because the do-while executes the statements before testing the condition, if the condition is true it will continue
27th May 2019, 1:10 PM
Andres0b0100
Andres0b0100 - avatar
0
Because do while loop always executes at least one time even if the condition is not true. It could be useful for some cases
27th May 2019, 2:41 PM
Hetbo.net
Hetbo.net - avatar