Double vs Triple Equals
The == and === operators don’t seem to make any difference; in fact, you might not have even heard of the triple-equals (===) operator. Here’s a quick demonstration:
$var1 = "1"; $var2 = 1;
So here we have 2 variables; both are different forms of 1. If we use the following code:
if ($var1==$var2) { echo "Double Equals returned they are the same!"; }else { echo "Double Equals said they are different!"; }
…But that’s incorrect. “1” and 1 are not equal. One is a string, while the other is an integer. Let’s try the same code with a Triple Equals.
if ($var1===$var2) { echo "Triple Equals returned they are the same!"; }else { echo "Triple Equals said they are different!"; }
Now it says they’re different, which is correct. What Double Equals basically does is translate all the parameters into strings. It tries it’s best to make everything match. Triple Equals is a little tougher, and decides that what is there is what it will compare. You should always use Triple Equals, because not only does it check value, it checks TYPE (string, int, etc.)