What are the potential pitfalls of comparing hashed passwords using the crypt() function in PHP?

When comparing hashed passwords using the crypt() function in PHP, a potential pitfall is that the function may not always return the same hash for the same password due to the use of different hashing algorithms or salts. To solve this issue, it is recommended to use the password_verify() function instead, which compares a plaintext password to a hashed password securely.

$hashed_password = crypt($password, $salt);

if (password_verify($password, $hashed_password)) {
    // Passwords match
} else {
    // Passwords do not match
}