I've no certainty here, but I strongly suspect that it's a Perlism that PHP partially took.
In Perl, $a == $b would be true -- just like in PHP. However, in Perl, you use string comparison ($a eq $b) when you want to compare strings. PHP doesn't seem to have string comparison outside of ==.
You wrote nasty code in PHP that you don't clearly understand, and aren't immediately either researching (and then documenting!) why you did what you did, or failing that, recoding for sanity. Once those little hacks calcify it's all down the tubes from there.