January 29, 2016

# Comparison Operators in PHP

In PHP, when we want to compare 2 values, we make use of comparison operators. These comparison operators are basically used with conditional statements and will return a boolean value (true or false). Most commonly used comparison operators are given below.

Operator | Meaning |
---|---|

$a == $b | $a is equal to $b |

$a != $b | $a is not equal to $b |

$a < $b | $a is less than $b |

$a > $b | $a is greater than $b |

$a <= $b | $a is less than or equal to $b |

$a >= $b | $a is greater than or equal to $b |

$a === $b | $a is equal to $b and they are of same data type. |

$a !== $b | $a is not equal to $b and they are also not of same data type. |