You use a single = to assign a value to a variable, as in
$x = 3;
You use double == to compare two values, to see if they are equal, as in
$x == 3 will be true
$x == 4 will be false
So by using a single = in an if() statement like so
if ($x = 4) {...}
means you assign the value 4 to $x, regardless of it's previous value, and if the operation is succesfull (which it always is) it will return true and the if() statement will always run.
There is also a third operator with three ===, which takes variable types into account when comparing. This should show the difference.
PHP Code:
$x = 3; // the number 3 $y = '3'; // the string '3'
if ($x == $y) { // this is true } if ($x === $y) { // this is false }
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
|