As Michael uggests we should take care not to compare the hash using == (or ===). Since PHP version 5.6 we can now use hash_equals().
So the example will be:
<?php
if (hash_equals($hashed_expected, $hashed_value) ) {
echo "hashes match!";
}
?>