What does !== comparison operator in PHP mean?
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?
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:
PHP's === Operator enables you to compare or test variables for both equality and type.
So !== is (not ===)
!==
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.
链接地址: http://www.djcxy.com/p/1800.html上一篇: 在PHP中!==和!=有区别吗?
下一篇: PHP中的!==比较运算符是什么意思?