For those without gmp support :
$hamming_distance = count(array_diff_assoc(str_split($string1), str_split($string2)));
And if you are not sure if your strings have equal length :
$hamming_distance = count(array_diff_assoc(str_split(str_pad($string1,strlen($string2)-strlen($string1),' ')), str_split(str_pad($string2,strlen($string1)-strlen($string2),' '))));