13

I saw

if($output !== false){
}

It's an exclamation mark with two equals signs.

It almost works like not equal. Does it has any extra significance?

random
  • 9,774
  • 10
  • 66
  • 83
Thejesh GN
  • 1,108
  • 2
  • 14
  • 28
  • see http://stackoverflow.com/questions/80646/how-do-the-equality-and-identity-comparison-operators-differ – VolkerK Aug 19 '09 at 06:25
  • and http://stackoverflow.com/questions/1139154/is-there-a-difference-between-and-in-php – VolkerK Aug 19 '09 at 07:18
  • possible duplicate of [Reference - What does this symbol mean in PHP?](http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php) – kapa Jun 07 '12 at 16:28

5 Answers5

32

They are the strict equality operators ( ===, !==) , the two operands must have the same type and value in order the result to be true.

For example:

var_dump(0 == "0"); //  true
var_dump("1" == "01"); //  true
var_dump("1" == true); //  true

var_dump(0 === "0"); //  false
var_dump("1" === "01"); //  false
var_dump("1" === true); //  false

More information:

Christian C. Salvadó
  • 807,428
  • 183
  • 922
  • 838
5

PHP’s === Operator enables you to compare or test variables for both equality and type.

So !== is (not ===)

Svetlozar Angelov
  • 21,214
  • 6
  • 62
  • 67
5

!== checks the type of the variable as well as the value. So for example,

$a = 1;
$b = '1';
if ($a != $b) echo 'hello';
if ($a !== $b) echo 'world';

will output just 'world', as $a is an integer and $b is a string.

You should check out the manual page on PHP operators, it's got some good explanations.

zombat
  • 92,731
  • 24
  • 156
  • 164
3

See this question: How do the equality (==) and identity (===) comparison operators differ?.

'!==' is the strict version of not equal. I.e. it will also check type.

Community
  • 1
  • 1
PatrikAkerstrand
  • 45,315
  • 11
  • 79
  • 94
2

yes, it also checks that the two values are the same type. If $output is 0, then !== will return false, because they are not both numbers or booleans.

Marius
  • 57,995
  • 32
  • 132
  • 151