Equal (==) compares two values after type changing one value to another. Identical compare values and types both and returns true only if they both are same. Some php examples to cover frequently covering cases:
Compare “0” and 0 using == and ===
<?php var_dump("0" == 0); var_dump("0" === 0); ?>
bool(true) bool(false)
Env: PHP 7.4.33 (Linux)
Compare “” and 0 using == and ===
<?php var_dump("" == 0); var_dump("" === 0); ?>
bool(true) bool(false)
Env: PHP 7.4.33 (Linux)
Compare “0” and “” using == and ===
<?php var_dump("0" == ""); var_dump("0" === 0); ?>
bool(false) bool(false)
Env: PHP 7.4.33 (Linux)
Note that “0” and “” do not match even when using ==
What matches with FALSE using ==
<?php var_dump(FALSE == FALSE); var_dump(NULL == FALSE); var_dump(0 == FALSE); var_dump("0" == FALSE); var_dump("" == FALSE); var_dump(array() == FALSE); ?>
bool(true) bool(true) bool(true) bool(true) bool(true) bool(true)
Env: PHP 7.4.33 (Linux)
What matches with NULL using ==
<?php var_dump(FALSE == NULL); var_dump(NULL == NULL); var_dump(0 == NULL); var_dump("0" == NULL); var_dump("" == NULL); var_dump(array() == NULL); ?>
bool(true) bool(true) bool(true) bool(false) bool(true) bool(true)
Env: PHP 7.4.33 (Linux)
Note that “0” does not match with NULL