The usage of == and === in php

Possible Duplicate:
What does “===” mean?

I am confused with the use of those operators in php, I am not quite sure when should I use === and when ==.

for example why/when should I write:

if( $some_method_that_returns_something_or_false() === FALSE) {
      //do stuff
}

and when with ==?

Also, does === means I must return bool FALSE or I can return 0? When it is considered an bad practice to use === or ==?

Also when putting something like this:

 if($some_method_that_returns_true_or_false()) {

 }

is that $some_method_that_returns_true_or_false() == TRUE or some_method_that_returns_true_or_false() === TRUE?


===意味着确切的值,所以对于真实它必须是真实的,而==检查值的含义,所以true也将是'1'或任何字符串的值。


== is used for checking equallity and === is used for checking the equality as well as type.

And

if($some_method_that_returns_true_or_false()) {

}

is checking for $some_method_that_returns_true_or_false() == TRUE

链接地址: http://www.djcxy.com/p/58598.html

上一篇: 什么做!==和===在PHP中意味着什么?

下一篇: 在PHP中使用==和===