PHP basic syntax comparison operators

Comparison operators, we learned a lot when we were in elementary school, they are:

## Less than or equal to ≤ is not equal to ≠ is equal to =
Explanation symbols
is greater than >
is less than <
Greater than or equal to
But in our case There is an additional operator in PHP:

Description Symbol Greater than > ##Less than Greater than or equal to is less than or equal to is not equal to is equal to Congruent (judgment type is equal) Congruent (judgment type is not equal) Let’s review the knowledge we learned in elementary school:
<
>=
<=
!=
== (the assignment is = sign, so == is specified as equal)
===
!==

x = 5

y = 6

x##x> y is wrong, because x is 5 and y is 6, so the judgment that x is greater than y is wrong

We learned judgment questions similar to this when we were in elementary school.The right and wrong in the computer are the true and false of the bool (Boolean) data type.

Then, can we use the if...else we learned before to determine the type?

 $y){ //真区间 echo '变量x 大于 变量y,成立'; }else{ //假区间 echo '变量x 大于 变量y,不成立'; } ?>

I think, if you graduate from elementary school. Less than, less than or equal to, size equal to, and not equal to will all be tested. Please experiment a few times. Moreover, it is completely possible to write silently!

The next key point is the demonstration, equal (==) and equal to all are also called judgment type equal (===).

Let's write a piece of code. Let's take a look at the two pieces of code. They are symbols of PHP Academy. Why is there such a big gap in the results?

The result of executing the following code is the true interval.

The result of executing the following code is a false interval.

We compared the differences and found:

The following code is === (three equal signs, we say it also has a name for judging type equals). And $x is an integer type 5. $y is a string type 5. Type PHP Academy, so a false interval is executed. In the above piece of code, the two equal signs do not determine the type, so the true interval is executed.

Continuing Learning
||
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!