Our Blog

News, thoughts & useful links

Contact: Skype , email or call
+44 (0) 131 556 6818

“===” compare operator and strcmp() or stricmp() in PHP

September 4th, 2008 by Anton

Have you ever run into trouble when using strcmp() function and the match found at position 0 ? strcmp() returns either an index of the first match or FALSE, if the match is not found. It is easy to see that FALSE and 0 can sometimes be interpreted by PHP as the same thing (when clearly they are not).

To avoid this hiccup from happening use “===” operator which means “equals and is of the same type”.


$str = "Look inside me";
$findMe = "Loo";
if (strcmp($str, $findMe) === 0) { ... match found at position 0 ... }


Comments are closed.