Why does (0 == 'Hello') return true in PHP?

后端 未结 5 1365
南方客
南方客 2020-12-03 16:53

Hey, if you have got the following code and want to check if $key matches Hello I\'ve found out, that the comparison always returns true

5条回答
  •  -上瘾入骨i
    2020-12-03 17:11

    In php, the string "0" is converted to the boolean FALSE http://php.net/manual/en/language.types.boolean.php

提交回复
热议问题