WEBVTT

00:00.710 --> 00:04.160
I welcome you back again to another video lecture in PHP.

00:04.160 --> 00:10.430
And in this lecture we go ahead and look more into if else statement.

00:16.850 --> 00:20.780
So in the previous lecture we are able to discuss about if our statement.

00:20.780 --> 00:28.940
And we actually dive in and we learned a little bit about if statement.

00:28.970 --> 00:31.280
Now let's go ahead and put that into practice.

00:31.280 --> 00:36.350
So I will be using Sonic for our maximum number.

00:36.380 --> 00:38.810
Let's go ahead and look at maximum numbers.

00:38.810 --> 00:40.250
So let me go ahead and see.

00:40.250 --> 00:44.900
We have a function called Max.

00:44.900 --> 00:52.610
And uh is go here I have us to print out the maximum of all these numbers.

00:52.610 --> 00:56.120
If I refresh this we have it as the maximum number.

00:56.150 --> 01:00.320
Now we got to learn how to use if statements to achieve this.

01:01.900 --> 01:05.020
Now let's go ahead and remove whatever we have right in here.

01:05.050 --> 01:09.100
And now I want to use if else statements to do this.

01:09.100 --> 01:15.340
Now go ahead and create a function and a legal function name.

01:15.370 --> 01:18.310
Be get max.

01:18.490 --> 01:24.400
So we can be able to get the maximum number and the the score and the.

01:24.730 --> 01:27.580
Now add an if statement right in here.

01:29.080 --> 01:34.570
So I'm going to pass in some parameters I'm going to create two variables of num1.

01:34.570 --> 01:39.250
And then I'll create another one num two.

01:39.460 --> 01:43.180
So now we'll go ahead and create a function.

01:43.180 --> 01:44.860
Let's see if statement.

01:44.860 --> 01:58.450
And then we go ahead and uh see if let me see num one because we want to compare which of these numbers

01:58.480 --> 02:00.130
is greater than the other.

02:00.130 --> 02:05.550
So if num one is greater than

02:07.410 --> 02:08.760
Num2.

02:09.300 --> 02:13.800
Now we want to check we're going to return Num1.

02:13.980 --> 02:18.450
We're going to say return Num1.

02:20.640 --> 02:23.970
So go ahead and return no one else.

02:24.000 --> 02:30.390
Let's go ahead and put our statement then else we go ahead and return.

02:30.420 --> 02:31.110
None two.

02:31.140 --> 02:34.530
So go ahead and return.

02:37.800 --> 02:40.740
Num2 so we're a semicolon.

02:40.740 --> 02:45.270
And now we have this function we just created right in here.

02:45.300 --> 02:51.570
And this function will enable us to be able to select between two numbers.

02:51.600 --> 02:55.620
Now let's go ahead and echo out whatever we have.

02:55.650 --> 02:58.950
We go ahead and see echo get math.

02:58.950 --> 03:01.440
So we're calling the function right in here.

03:01.440 --> 03:06.660
So we can be able to input pitch in or pass in, so on parameters in a.

03:06.840 --> 03:11.700
Then go ahead and say the first one is 90, and then the next one is uh 180.

03:12.450 --> 03:14.250
And put a semicolon at the end.

03:14.280 --> 03:16.680
Now let's go ahead and refresh and check.

03:16.680 --> 03:19.560
We have 180 as the maximum.

03:19.560 --> 03:24.840
So if we go ahead and make this to be 219 and save let's refresh.

03:24.840 --> 03:27.030
We have 290 as the maximum.

03:27.030 --> 03:29.460
So this is just between two numbers.

03:29.760 --> 03:32.520
Um number one and number two.

03:32.580 --> 03:38.490
So what if we have like to select between three or 4 or 5 numbers.

03:38.490 --> 03:40.800
How can you be able to achieve this.

03:41.400 --> 03:42.210
You understand.

03:42.240 --> 03:43.650
How can you be able to achieve this.

03:43.650 --> 03:55.140
Now let's go ahead and uh, check out how can we go to do this if this is true between two or between

03:55.140 --> 03:56.310
3 or 4 numbers.

03:56.310 --> 04:05.630
So making that to be more complex now we're going to do is let's go ahead and uh, Comment on this so

04:05.630 --> 04:07.670
that we can be able to close this.

04:07.760 --> 04:10.580
So go right in here and increase this.

04:10.580 --> 04:13.190
So I just commented on this right now.

04:14.210 --> 04:15.680
Now what do we need to do.

04:15.710 --> 04:16.820
Let's go over here.

04:16.820 --> 04:20.480
And uh I'm going to create a different function.

04:20.480 --> 04:23.420
Because the reason why I like this is able to pull a random name.

04:23.450 --> 04:27.500
It can be able to check them out and need to help you to understand more on this.

04:27.500 --> 04:30.260
So let's go ahead and create unofficial.

04:30.260 --> 04:34.400
And I want to also name that to be get Max.

04:35.420 --> 04:41.180
And now I'm going to pass in some parameters of same one.

04:41.960 --> 04:49.220
And uh next one is number two and number three.

04:50.000 --> 04:50.390
All right.

04:50.420 --> 04:52.070
So this is a number three.

04:52.340 --> 04:56.480
Now let's go ahead and just to extend like you did before.

04:56.480 --> 04:59.570
So you got here right inside here.

04:59.660 --> 05:07.300
So we're going to check is in the if statement for Volume one, number two and number three.

05:07.630 --> 05:08.800
And the guidance.

05:08.830 --> 05:11.590
See if and then.

05:11.920 --> 05:14.380
And see if no one.

05:16.150 --> 05:19.630
If no one is greater than.

05:22.270 --> 05:25.720
Or equal to num2.

05:27.100 --> 05:33.820
So if no one is greater than or equal to num2, then we're going to use the ampersand to also check

05:33.820 --> 05:36.490
if number one is greater than or equal to num three.

05:36.490 --> 05:38.590
So go ahead and say ampersand.

05:38.620 --> 05:39.550
Then.

05:41.950 --> 05:49.870
If no one is also greater than or equal to number three.

05:49.960 --> 05:52.360
So you can see how I'm able to do that.

05:52.360 --> 06:01.540
So the first time I checked, if no one is greater than or equal to num two, and also if num one is

06:01.540 --> 06:03.430
greater than or equal to number three.

06:03.430 --> 06:08.610
So in this case, if no one is greater written on words number two and number three.

06:08.640 --> 06:11.310
That means I'm going to return no one.

06:11.310 --> 06:14.550
So go ahead and return.

06:18.060 --> 06:18.870
No one.

06:18.870 --> 06:19.500
So please.

06:19.500 --> 06:20.670
Semicolon at the end.

06:20.850 --> 06:27.060
Now else if I say else if.

06:27.330 --> 06:30.000
So we're going to make it three conditionals right in here.

06:30.030 --> 06:33.060
We're going to check for a if.

06:33.060 --> 06:35.280
And we're going to check for number one.

06:35.310 --> 06:36.480
We're going to check for number two.

06:36.510 --> 06:39.450
And we're going to check going to check for number three.

06:39.480 --> 06:51.360
Now to check for number two we go ahead and say else if and number two is greater than or equal to number

06:51.360 --> 06:55.110
one just like we did is return on record.

06:55.110 --> 07:02.160
So number one then absent that means and also check for number three.

07:02.160 --> 07:09.560
So number two is greater than or equal Quarter number three.

07:09.950 --> 07:10.520
Okay.

07:10.550 --> 07:17.750
Now we're going to return number two because it means that number two is greater than.

07:18.890 --> 07:20.600
So return.

07:22.880 --> 07:23.900
No.

07:23.930 --> 07:26.540
Two press Omicron on the end.

07:26.660 --> 07:31.070
So else it means that num three is what?

07:31.100 --> 07:31.970
The greatest.

07:33.230 --> 07:34.880
That is what it means right in here.

07:34.910 --> 07:37.760
So return.

07:41.000 --> 07:41.930
NUM three.

07:41.930 --> 07:43.850
So the semicolon at the end.

07:43.880 --> 07:47.030
Now you have to do this very well.

07:47.030 --> 07:48.770
And that is very good.

07:48.800 --> 07:55.580
So what remains now is to go ahead and, uh, equal uh get Max.

07:56.240 --> 07:57.590
So get Max.

07:57.620 --> 08:02.750
Then we are going to go ahead and pass in the parameters you want to check.

08:02.780 --> 08:05.090
Maybe the first one I'm going to check for 50.

08:05.120 --> 08:07.790
I want to check for 87.

08:07.820 --> 08:11.360
I'm going to check for 54 now.

08:11.360 --> 08:13.430
Going to help with semicolon at the end.

08:13.490 --> 08:16.220
Let's save this refresh and check it out.

08:16.340 --> 08:22.940
So we have an error at line 12 that says uh.

08:23.600 --> 08:24.890
Unexpected token.

08:24.920 --> 08:26.060
Else if.

08:27.140 --> 08:29.900
So what happened?

08:29.900 --> 08:30.920
Right in here?

08:31.880 --> 08:34.370
Unexpected to call our Steve.

08:34.490 --> 08:40.400
So let me go ahead and check and, uh, know what actually happened here.

08:41.360 --> 08:46.130
So for what I just saw here, it says unexpected token.

08:46.160 --> 08:53.840
Else if means that, uh, for if statements, we actually deleted the curly brace here.

08:53.870 --> 08:55.460
Now, go ahead and close this.

08:55.460 --> 08:57.320
And the work was this.

08:57.350 --> 09:03.740
We can also see that, uh, we didn't close the function because we deleted that.

09:03.740 --> 09:05.930
So that is a mistake from our side.

09:05.960 --> 09:07.010
Go ahead and set this.

09:07.010 --> 09:13.420
So we've been able to close the deflation and we've been able to close the if statement.

09:13.420 --> 09:15.130
So go ahead and refresh this.

09:15.130 --> 09:16.150
Let's check it out.

09:16.390 --> 09:20.050
Now you can see that it's seven is the greatest.

09:20.080 --> 09:26.860
Now only if we make this to be 154 and no longer 54 I refresh this.

09:26.890 --> 09:29.710
You can see we have 154.

09:29.710 --> 09:35.230
So let's go ahead and make this to be 250 and save this refresh.

09:35.260 --> 09:39.010
We have 250 as the maximum number.

09:39.010 --> 09:45.130
So in that way we have been able to put in the if else statement into practice.

09:45.130 --> 09:51.760
And you can see that it actually worked very well, getting the maximum of three numbers and the maximum

09:51.790 --> 09:53.890
of two numbers respectively.

09:53.890 --> 09:55.690
So we're not done with that.

09:55.690 --> 10:01.930
Check out more on that and if you have any questions on that this video lecture, please use the question

10:01.930 --> 10:03.340
and answer section.

10:03.760 --> 10:06.700
And I'm going to get back to you as soon as possible.

10:06.730 --> 10:07.690
Thank you so much.

10:07.690 --> 10:10.900
And I'm going to see you in the next video lecture.
