Can for loop execute without initialization? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can for loop execute without initialization?

23rd Dec 2019, 2:31 PM
Nitya
Nitya - avatar
2 Answers
+ 2
Yes, for loop can execute without initialization IF a variable used for loop counter, or a variable needed is already defined before the loop. For example: $i = 1; for(; $i <= 5; $i++) // no initiailization { echo $i . '<br />'; }
24th Dec 2019, 12:01 PM
Ipang
+ 1
Thank you.
26th Dec 2019, 11:49 AM
Nitya
Nitya - avatar