What is the difference between password_hash and password_verify in PHP, and when should each be used?
`password_hash` is used to securely hash passwords before storing them in a database, while `password_verify` is used to verify a password against a hashed password. `password_hash` should be used when creating a new password or updating an existing one, and `password_verify` should be used when checking if a user-entered password matches the hashed password stored in the database.
// Hashing a password
$password = "secret_password";
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// Verifying a password
$user_password = "user_entered_password";
if (password_verify($user_password, $hashed_password)) {
echo "Password is correct!";
} else {
echo "Password is incorrect!";
}