Wednesday 21 December 2016

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?


Answer



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:




No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...