-7

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?

Community
  • 1
  • 1
ignite1688846
  • 147
  • 3
  • 12

2 Answers2

3

=== means exact value, so for true it has to be true, while == checks for the meaning of the value, so true will be also a value of '1' or a whatever String.

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

Yogesh Suthar
  • 30,424
  • 18
  • 72
  • 100