Wednesday 6 March 2019

comparison - Is there a difference between !== and != in PHP?




Is there a difference between !== and != in PHP?


Answer



The != operator compares value, while the !== operator compares type as well.



That means this:



var_dump(5!="5"); // bool(false)
var_dump(5!=="5"); // bool(true), because "5" and 5 are of different types

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...