-1

Possible Duplicate:
php == vs === operator
Reference - What does this symbol mean in PHP?

In PHP, what is the difference between == and ===? Also, what's the difference between != and !==? Appreciate the help!

Community
  • 1
  • 1
Willem Ellis
  • 4,886
  • 7
  • 38
  • 55
  • 9
    Let me guess, you have spent no time googling this? – Bali C Feb 02 '12 at 17:10
  • 3
    As a note, searching for "PHP ===" on this site is not helpful. – tster Feb 02 '12 at 17:12
  • 1
    @baudday, just realized you are the OP. Yeah, I tried a couple obvious googles myself and didn't see any top results. Searching on this site for it sucks too. Seems like something that should be improved. Searching for "===" on a programming site should be treated pretty well. – tster Feb 02 '12 at 17:16
  • yeah instead I got -5 votes haha. I was just curious cause I'm using `strpos()` to search a string and noticed `!==`. I had been using `!=` so I wanted to know which was correct. – Willem Ellis Feb 02 '12 at 17:18
  • @baudday google or not, there's still the php.net manual; == and === are, as in any language I think, operators. A search for "Php operators" there would have yielded a better result. A piece of advice: always head for the manual, it's pretty comprehensive – Damien Pirsy Feb 02 '12 at 17:55

1 Answers1

3

From http://us.php.net/manual/en/language.operators.comparison.php

$a == $b    Equal   TRUE if $a is equal to $b after type juggling.
$a === $b   Identical   TRUE if $a is equal to $b, and they are of the same type.
$a != $b    Not equal   TRUE if $a is not equal to $b after type juggling.
$a <> $b    Not equal   TRUE if $a is not equal to $b after type juggling.
$a !== $b   Not identical   TRUE if $a is not equal to $b, or they are not of the same type.
brent
  • 1,709
  • 2
  • 13
  • 15
  • 2
    just to add an example: 0 == false, but 0 !== false, the prime example for its use being the strpos function (http://php.net/manual/de/function.strpos.php) – roman Feb 02 '12 at 17:14
  • AWESOME! The whole reason I'm asking this actually has to do with `strpos()`! – Willem Ellis Feb 02 '12 at 17:16