What does this !==
mean in php and is there any doc's on it?
5 Answers
PHP comparison operators, "Not identical" (5th in the table)
This operator works much like != but also checks the type of the operands. For example:
3 != '3'
is false
, but 3 !== '3'
is true
.

- 428,835
- 81
- 738
- 806
==
is the comparison operator you're familiar with: if two values are equivalent, they ==
each other. There's some type coercion that goes on before the comparison.
4 == '4' // true: equivalent value, different type
===
is a more strict comparison that requires that values be of the same type.
4 === 4 // true: same value, same type
'4' === '4' // true: same value, same type
4 === '4' // false: equivalent value, different type
!==
is the opposite of the strict comparison operator, so it is true when two values are of a different type or different value or both.
4 !== 3 // true: different value, same type
4 !== '4' // true: equivalent value, different type
'4' !== 3 // true: different value, different type
'4' !== '3' // true: different value, same type
4 !== 4 // false: same value, same type

- 83,922
- 18
- 153
- 160
It means "not equal or not the same type".
This shows the difference between !=
and !==
:
"5"!=5 //returns false
"5"!==5 //returns true

- 44,854
- 16
- 96
- 107
That is the not identical operator
$a !== $b
Returns TRUE if $a is not equal to $b, or they are not of the same type.
For example, it is used to check if a variable is false and not 0, since 0 is the same that false for PHP.
$bar = 0;
if ($bar != false) { echo '$bar != false'; } // won't output the text
if ($bar !== false) { echo '$bar !== false'; } // will output the text

- 1,212
- 7
- 23
- 36
-
Indeed, particularly useful if a function can return an resulting integer on success or false on failure. You will need to check "!== false" as "!= false" could be success and returning the integer 0; – drew Nov 27 '10 at 11:51
!=
is used for value only
but
!==
is used for value and type both
suppose:
$a = "5"; // String
$b = 5; // Integer
$a!=$b // false
$a!==$b // true
That's the difference.

- 669
- 7
- 20