PHP Equality Operators

Equality operators are used to compare two values, testing for equivalence.

Example Label Outcome
$a == $b Is equal to True if $a and $b are equivalent
$a != $b Is not equal to True if $a is not equal to $b
$a === $b Is identical to True if $a and $b are equivalent and $a and $b have the same type

It is a common mistake for even experienced programmers to attempt to test for equality using just one equal sign (e.g., $a = $b). Keep in mind that this will result in the assignment of the contents of $b to $a and will not produce the expected results.





Content