The basic principle of for loops is that it will repeat a block of codes the number of times you specify, using not only a condition but also the initialization in the beginning and the increment at the end.
So how much you want to increment your variable determines the number of times your variable loops by.
So, it is a bit more complex to write. However it looks good , it does the job and its very compact.
Now we write 'for'
so you have got three parts of your code here,and your block and that is all you need and your content can go here.
So, I am going to say 'echo' here and let's create a variable 'num'. So, we have echoed out 'num'.
In here, we write num =1, not = = 1 because we are setting the variable num to the value of 1.
Then we have a condition. For eg, while num < = to 10
Then, we have the increment values. So, we are going to have num ++ and the loop is done.
So, we type 'For', and our variable num=1
Then we have our condition 'While num< =10, the loop will continue, and then we have num ++
As you can see this is much more useful than having num ++ down below .
and we need not declare this up here.
It can be declared inside these parentheses.
O.K., I forgot the line-break.
Iâ€™ll add a line break on to the end of this.
Refresh.
There you go.
You've got your loop ten times.
And as it has been specified in such a way it will loop only when num is less than or equal to 10.
After that the loop will break and you may continue with the rest of the script.
This is a bit more complex but once you learn the basics you will find it a lot easier .
Thanks for watching.