I'm learning about cakephp, and I see much conditionals like:
if( x === y){
}
I've looked for it, but I don't find anything.
I'm learning about cakephp, and I see much conditionals like:
if( x === y){
}
I've looked for it, but I don't find anything.
== wil do auto type conversion, === won't
This means that:
0 == "0" evaluates to TRUE, because internally when comparing strings and numbers, a string is converted to a number when using ==.
0 === "0" evaluates to FALSE, there is no type conversion done and a integer 0 is not equal to a string.
More info in the documentation and more documentation.
== compares the values of two variables. If they are of different types, they are converted to a common type and then compared.
===, on the other hand, is more strict. It requires the two sides to be of the same type as well.
php> = 5 == "5"
true
php> = 5 === "5"
false