Comparison Operators

C

How Can We Help?

PHP comparison operators allows you to compare two values with each other.

Below is a table of all the different comparison operators that are available for PHP

Comparison Operators
ExampleNameResult
$a == $bEqualTRUE if $a is equal to $b.
$a === $bIdenticalTRUE if $a is equal to $b, and they are of the same type. (introduced in PHP 4)
$a != $bNot equalTRUE if $a is not equal to $b.
$a <> $bNot equalTRUE if $a is not equal to $b.
$a !== $bNot identicalTRUE if $a is not equal to $b, or they are not of the same type. (introduced in PHP 4)
$a < $bLess thanTRUE if $a is strictly less than $b.
$a > $bGreater thanTRUE if $a is strictly greater than $b.
$a <= $bLess than or equal toTRUE if $a is less than or equal to $b.
$a >= $bGreater than or equal toTRUE if $a is greater than or equal to $b.

About the author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

About Author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

Follow Me