Does PHP negation check with `!` coprrespond to `!=` or to `!==`?

后端 未结 4 637
梦如初夏
梦如初夏 2021-01-27 18:34

In PHP, is

if(!$foo)

equivalent with

if($foo != true)

or with

if($foo !== true)
4条回答
  •  再見小時候
    2021-01-27 19:01

    Note that,

    == OR != compares the values of variables for equality, type casting as necessary. === OR !== checks if the two variables are of the same type AND have the same value.

    This answer will give you better explanation of this concept: https://stackoverflow.com/a/80649/3067928

提交回复
热议问题