Take note of the `length` parameter: "The default value is the largest of the length of the str compared to the length of main_str less the offset."
This is *not* the length of str as you might (I always) expect, so if you leave it out, you'll get unexpected results. Example:
$hash = '$5$lalalalalalalala$crypt.output.here';
var_dump(substr_compare($hash, '$5$', 0)); # int(34)
var_dump(substr_compare($hash, '$5$', 0, 3)); # int(0)
var_dump(PHP_VERSION); # string(6) "5.3.14"