I welcome you back again to another video lecture in PHP.
And in this lecture we go ahead and look more into if else statement.
So in the previous lecture we are able to discuss about if our statement.
And we actually dive in and we learned a little bit about if statement.
Now let's go ahead and put that into practice.
So I will be using Sonic for our maximum number.
Let's go ahead and look at maximum numbers.
So let me go ahead and see.
We have a function called Max.
And uh is go here I have us to print out the maximum of all these numbers.
If I refresh this we have it as the maximum number.
Now we got to learn how to use if statements to achieve this.
Now let's go ahead and remove whatever we have right in here.
And now I want to use if else statements to do this.
Now go ahead and create a function and a legal function name.
Be get max.
So we can be able to get the maximum number and the the score and the.
Now add an if statement right in here.
So I'm going to pass in some parameters I'm going to create two variables of num1.
And then I'll create another one num two.
So now we'll go ahead and create a function.
Let's see if statement.
And then we go ahead and uh see if let me see num one because we want to compare which of these numbers
is greater than the other.
So if num one is greater than
Num2.
Now we want to check we're going to return Num1.
We're going to say return Num1.
So go ahead and return no one else.
Let's go ahead and put our statement then else we go ahead and return.
None two.
So go ahead and return.
Num2 so we're a semicolon.
And now we have this function we just created right in here.
And this function will enable us to be able to select between two numbers.
Now let's go ahead and echo out whatever we have.
We go ahead and see echo get math.
So we're calling the function right in here.
So we can be able to input pitch in or pass in, so on parameters in a.
Then go ahead and say the first one is 90, and then the next one is uh 180.
And put a semicolon at the end.
Now let's go ahead and refresh and check.
We have 180 as the maximum.
So if we go ahead and make this to be 219 and save let's refresh.
We have 290 as the maximum.
So this is just between two numbers.
Um number one and number two.
So what if we have like to select between three or 4 or 5 numbers.
How can you be able to achieve this.
You understand.
How can you be able to achieve this.
Now let's go ahead and uh, check out how can we go to do this if this is true between two or between
3 or 4 numbers.
So making that to be more complex now we're going to do is let's go ahead and uh, Comment on this so
that we can be able to close this.
So go right in here and increase this.
So I just commented on this right now.
Now what do we need to do.
Let's go over here.
And uh I'm going to create a different function.
Because the reason why I like this is able to pull a random name.
It can be able to check them out and need to help you to understand more on this.
So let's go ahead and create unofficial.
And I want to also name that to be get Max.
And now I'm going to pass in some parameters of same one.
And uh next one is number two and number three.
All right.
So this is a number three.
Now let's go ahead and just to extend like you did before.
So you got here right inside here.
So we're going to check is in the if statement for Volume one, number two and number three.
And the guidance.
See if and then.
And see if no one.
If no one is greater than.
Or equal to num2.
So if no one is greater than or equal to num2, then we're going to use the ampersand to also check
if number one is greater than or equal to num three.
So go ahead and say ampersand.
Then.
If no one is also greater than or equal to number three.
So you can see how I'm able to do that.
So the first time I checked, if no one is greater than or equal to num two, and also if num one is
greater than or equal to number three.
So in this case, if no one is greater written on words number two and number three.
That means I'm going to return no one.
So go ahead and return.
No one.
So please.
Semicolon at the end.
Now else if I say else if.
So we're going to make it three conditionals right in here.
We're going to check for a if.
And we're going to check for number one.
We're going to check for number two.
And we're going to check going to check for number three.
Now to check for number two we go ahead and say else if and number two is greater than or equal to number
one just like we did is return on record.
So number one then absent that means and also check for number three.
So number two is greater than or equal Quarter number three.
Okay.
Now we're going to return number two because it means that number two is greater than.
So return.
No.
Two press Omicron on the end.
So else it means that num three is what?
The greatest.
That is what it means right in here.
So return.
NUM three.
So the semicolon at the end.
Now you have to do this very well.
And that is very good.
So what remains now is to go ahead and, uh, equal uh get Max.
So get Max.
Then we are going to go ahead and pass in the parameters you want to check.
Maybe the first one I'm going to check for 50.
I want to check for 87.
I'm going to check for 54 now.
Going to help with semicolon at the end.
Let's save this refresh and check it out.
So we have an error at line 12 that says uh.
Unexpected token.
Else if.
So what happened?
Right in here?
Unexpected to call our Steve.
So let me go ahead and check and, uh, know what actually happened here.
So for what I just saw here, it says unexpected token.
Else if means that, uh, for if statements, we actually deleted the curly brace here.
Now, go ahead and close this.
And the work was this.
We can also see that, uh, we didn't close the function because we deleted that.
So that is a mistake from our side.
Go ahead and set this.
So we've been able to close the deflation and we've been able to close the if statement.
So go ahead and refresh this.
Let's check it out.
Now you can see that it's seven is the greatest.
Now only if we make this to be 154 and no longer 54 I refresh this.
You can see we have 154.
So let's go ahead and make this to be 250 and save this refresh.
We have 250 as the maximum number.
So in that way we have been able to put in the if else statement into practice.
And you can see that it actually worked very well, getting the maximum of three numbers and the maximum
of two numbers respectively.
So we're not done with that.
Check out more on that and if you have any questions on that this video lecture, please 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.