Where are your values for $string1 and $string2 coming from?
I had problems after comparing a string from a form and a string from a query field in postgres, where the string value came from a field of type CHAR(8). Inspection of the string lengths showed this field to be 8 even if a value of 3 characters was originally inserted (over the web with php).
I got around this by using the trim function, so you could do something like this:
if (strcmp($String1, trim($String2)) ==0 ) {
do stuff;
}