Comparison Operators (Chapter 5)
Main Lab 4 Page
Complex logic is possible in PHP, thanks to the use of If statements, and comparison operators. This allows the use of conditional statements, so some commands only run if certain conditions are met.
Operator | Definition |
---|---|
==
|
Equal To |
!=
|
Not equal to |
>
|
Greater than |
<
|
Less than |
>=
|
Greater than or equal to |
<=
|
Less than or equal to |
All six logical operators are demonstrated in the following block of PHP code:
Original value of $a is 21 and $b is 15
TEST 1: $a is not equal to $b
TEST 2: $a is not equal to $b
TEST 3: $a is greater than $b
TEST 4: $a is not less than $b
TEST 5: $a is greater than or equal to $b
TEST 6: $a is not less than or equal to $b