We just saw how to conditionally executed code using an F statement which uses a boolean value to decide
whether to run some cold or not.
In addition to getting a billion value from a function we can also get these values by comparing one
value to another
in P HP.
We have several comparison operators.
We use these to see if two values are equal not equal.
If one is bigger than the other and so on the result of comparing two values always results in a billion
value of true are false.
Let's look at an example.
We'll begin by comparing two values to see if they're equal.
We do this with two equal signs like this.
If we look at this in the browser we get false because three clearly does not equal four.
If we change this so that the values are equal
then in the browser we get true because 4 is equal to 4.
In addition to comparing two values for equality we can also compare two values to see if they aren't
equal to each other.
The result of using this operator is true if the values aren't equal and false if they are.
We can see if one value is less than another.
If a value is greater than another if one is less than are equal to another and if a value is greater
than are equal to another
there are a couple of other comparison operators but will look at those later.
Let's look at another example.
First let's add a variable and then if statement that uses the result of a comparison as its condition.
So here if the value of this variable is equal to twenty one will print out this message and if it's
not it will print out this message when we run this code.
We get the first message because the value is indeed equal to twenty one.
Let's try another comparison operator.
We'll change it to the not equal operator like that.
Now in the browser we get false.
This is because 21 not being equal to 21 is false.
Let's try another one.
If we change the age to 18 for example and the operator to less than
now in the browser we get true because 18 is less than 21.
Let's change the value of the variable back to 21
and try the.
Greater than operator.
Now in the browser we get false because 21 isn't greater than 21.
But if we change it to the Greater than are equal to operator then we get true because 21 isn't greater
than but it is equal to twenty one.
So by using these comparison operators we can compare two values to get a boolean result that we can
then use in control structures.