I will call you back again to our another video lecture in PHP.
And in this video lecture I will go ahead and teach you about why in PHP.
All right.
So in PHP we have what is called a loop system, which makes a program to run repeatedly.
It makes a program to be able to execute multiple times.
Let's go ahead and say I want to equal let's say equal one plus semicolon and save this.
And let's refresh this one.
I'll go ahead and copy this.
Then I'll go ahead and paste this multiple times.
All right.
So I'm going to say equal two equal three equal four and five.
Now let's save this.
So if I got it on a fresh piece, have one, two, three, four, five.
You see that?
Now if you want to, you can actually put that to be one output to break.
And in a way I can go ahead and copy this and press ahead and paste this.
Right here.
So because it changes again to 234 and five.
So this kind of refreshes and check it out.
So 12345.
So you can see how long it takes me.
It takes me about uh five lines of code to be able to print out 1234, five.
Now imagine if I want to print out this 1 million or I want to print out 2 million.
It means I have to equal out these four up to 2 or 3 million.
Now I'll go ahead and get rid of this random of this, and we'll show you how we can be able to do that
using a loop system.
So that is if you want to be able to print out just like we did this.
Now let's go ahead and create a variable and uh, let me say um variable known.
So I'm going to call that to be known.
And we want to print out numbers.
And uh num is equal to one starting from one.
That is where I want to start.
Now what I need now is I have to create a statement called a while loop.
So is a kind of a loop system called Y.
And I want to hit on enter.
You see that it gives the condition by itself.
So y the very first one is uh the variable name.
So y known.
You can change that to any name is less than or equal to ten.
Okay.
Let me start with ten.
That is what is given there.
I can say maybe 20 or 5000 millions and so on.
Now you go right in here A and that is the condition we are looking at.
We are always going to take from 1 to 10.
Now how are you going to do that?
I will now go ahead and echo and will pass in a string right in there, and I will pass in that variable
we just created.
So known.
And then for anytime I pass known, I want to move to the next line so that you can be able to see the
variable whatever we are printing out.
So now let's go ahead and print this out.
I save this and you can see I have one being printed to infinity.
Now what happens is that we do give a condition that we want this to be able to increment to one, two,
three.
So whenever it comes here it says one is less than or equal to ten.
It brings that out whenever it comes.
It said one is less than or equal to ten.
It prints that out.
And if you can watch my system, I'm scrolling down and this is printing to infinity.
You understand.
So That is an infinite loop.
You can see I'm still squaring down.
So now what I want to do is I want to give a condition that when one comes is printed at the first time,
it goes back to the condition at check and it will increment and then go back to the condition.
I check and come back and increment until it gets to ten.
Now I'll go over here and I'm going to say put in the variable name known, and I'm going to see known
increment two times.
So that addition means increment twice.
So what it means is that I will refresh this.
Let's check it out.
It goes the first one.
You see that I need to print 1 to 10.
It goes the first time and print out one.
Then it goes back and check the condition.
And the condition sees increment again and one to the variable making it two.
Then it prints out two.
Then it goes back again and check and it says add another one to that and check if it is less than ten.
It increments again, and when it gets to ten it says keep adding, but always check if it is below
ten.
So when it gets to ten it adds.
And that is that is 11.
It goes back as a no 11 is greater than ten, 11 is not less than.
And it breaks out.
So it stops at anything less than ten.
So if you set this to start from zero, go ahead and put a zero right in and save this.
I refresh this and you can see I started from zero.
And it remains to one two because it starts at 12345678 9 to 10.
Now I said this is less than or equal to ten.
What if I say this is less than ten and the guy had on a fresh.
You can see that ten is not included because it must be less than ten.
What if I said less than or equal to ten.
It means that ten is included.
So this is about while loop in PHP.
So I believe that's all from the explanation you got.
How and why we are using while loop in case you want to print out hundred.
So you can actually use it to print out hundred and say this is hundred.
And let's go ahead and okay, let me just select 20 because this might be very long.
Let's say 20 and refresh.
And we get down.
You can see I have 20 down here.
So if I do dot 200 I have to scroll down all the way down to hundred for you to see that.
So go ahead and play around with them.
You can do that 200 and scroll down to the bottom of your browser.
And you can see 100 down there.
So check it out, play around with it.
And if you have if you have any question, go ahead and use the question and answer section.
And I'm going to get back to you as soon as possible.
Thank you so much.
And I'm going to see you in the next video lecture.