-3
可能重複:
Why does PHP consider 0 to be equal to a string?
php string comparasion to 0 integer returns true?IF語句總是在PHP執行
看來,作爲一個在PHP的if語句,其中一個功能some_function()返回零
<?php
if(some_function() == "whatever_you_want") { ... }
statem ent將始終執行,因爲
<?php
echo some_function() == "whatever_you_want";
然後是TRUE。
爲什麼要以這種直觀的方式表現PHP?
函數返回什麼? 「零」不是一回事。 – deceze
將整數(0)與字符串進行比較的意義何在?如果你堅持這樣做,那麼使用'==='運算符。 – Havelock
http://php.net/manual/en/types.comparisons.php – Sotiris