WEBVTT

00:00.620 --> 00:04.280
I'll call you back again to another video lecture in PHP.

00:04.280 --> 00:09.620
And in this video lecture I'll go ahead and teach you about do while loop.

00:15.080 --> 00:20.870
As I said in the previous lecture, we discussed about a while loop.

00:20.870 --> 00:25.160
And in this video lecture we're going to talk about do while loop.

00:25.370 --> 00:28.610
Now this is what we did in the previous lecture.

00:28.610 --> 00:30.980
We actually did this.

00:30.980 --> 00:34.340
And when you run this code it gives you this.

00:34.640 --> 00:42.800
What is defined between while loop and do while loop is that in while loop we always check the condition

00:42.800 --> 00:47.150
which is this before we execute and go back and check the condition.

00:47.150 --> 00:52.520
But in do while loop, we first of all execute the program before we check the condition.

00:52.610 --> 00:57.860
Then go ahead and say that this is 11 and that 11 is less than ten.

00:57.890 --> 01:03.170
If I run this code, you see, I don't have anything like 11 right in here.

01:03.200 --> 01:10.280
Now do while loop is go ahead and take this white condition out of this white condition and I'm going

01:10.310 --> 01:12.440
to place it right in here.

01:13.220 --> 01:20.720
So that is the while loop and then put a semicolon at the end and this place removed the while loop.

01:20.750 --> 01:25.160
I'll go ahead and put do and then I'll go ahead and save.

01:25.760 --> 01:32.870
So if I run this program 11, we first of all we printed out the body will be printed out before we

01:32.870 --> 01:34.610
go ahead to check the condition.

01:34.640 --> 01:37.220
Now let's go ahead and run this code and check it out.

01:37.880 --> 01:42.710
11 so it has executed is 11 and nothing again happened.

01:42.740 --> 01:49.490
The reason is because in the while loop we first of all is the body before checking for the condition.

01:49.520 --> 01:56.590
Now if I go back here and put this to be equal to one and save this and run this code and have 1 to

01:56.590 --> 01:59.240
10, one was actually printed out.

01:59.270 --> 02:05.330
Then it goes and check the condition and came back to print out the other ones.

02:05.330 --> 02:09.590
So this is the difference between while loop and do while loop.

02:09.590 --> 02:13.220
So I hope that is clear and is very straightforward.

02:13.220 --> 02:15.050
So go ahead and put it on your own.

02:15.050 --> 02:16.550
Check it out, play around with it.

02:16.550 --> 02:22.190
And if you have any questions on this, please go ahead and use the question and answer section.

02:22.190 --> 02:24.830
And I'm going to get back to you as soon as possible.

02:24.860 --> 02:25.820
Thank you so much.

02:25.820 --> 02:28.760
And I'm going to see you in the next video lecture.
