13
votes

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?

5

5 Answers

32
votes

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:

5
votes

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

So !== is (not ===)

4
votes

!== 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.

3
votes

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.

2
votes

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.