Possible duplicates:How do the comparison operators for equality (== double equals) and identities (=== triple equals) differ?Link - what does this symbol mean in PHP?php is not equal! = and! ==
What are the operators !==and ===in this code snippet?
!==
===
if ( $a !== null ) // do something if ( $b === $a ) // do something
They are strict type comparison operators. They not only check the meaningbut also type .
Consider a situation where you are comparing numbers or strings:
if (4 === 4) // same value and type { // true }
but
if (4 == "4") // same value and different type but == used { // true }
and
if (4 === "4") // same value but different type { // false }
This applies to both objects and arrays.
, : == ===
==
===,
:
.
1 == 1 1 == "1" 1 === 1 1 !== "1" true === true true !== "true" true == "true"
true. , @mbeckish
=== .
, "1" == 1 true, "1" === 1 false. fonctions, 0 False (, strpos).
"1" == 1
"1" === 1
, strpos 0 0 == false
if (strpos('hello', 'hello world!'))
, , :
if (strpos('hello', 'hello world!') !== false)
double = , // , // .
= - , , // - .
! ==
true , . : 1 === 1 "1" === 1 1 === "1" "1" === "1"
, ==,
==, .
if( '1' == 1 ) { echo 'yes'; }
, .
===, .
if( '1' === 1 ) { /* this will not work */ }
, '1' string, 1 - integer number
'1'
string
1
integer
number
- - : D
if( (integer) '1' === 1 ) { echo 'this works'; }
'1' integer