Comparison operators will compare multiple values among themselves on the name. For example, is a variable in $a
the same as $b
? Or bigger? We will make comparisons with these operators.
Let's show the comparison operators on a table:
Operator | Name | Usage |
---|---|---|
== | Equal | $a == $b |
=== | Equivalent | $a === $b |
!= | Not equal | $a != $b |
!== | Not equivalent | $a !== $b |
< | Smaller | $a < $b |
> | Bigger | $a > $b |
<= | Small and equal | $a <= $b |
>= | Greater than and equal | $a >= $b |
In the comparison operator, the double equal sign, there is a small detail to consider. A double equal sign is used to compare two values, and a single equal sign is used to assign a value. So make sure you don't make odd equals when you want to use the equals double equals operator.
Follow my blog for more baransel.dev.