What is the purpose of using password_verify() function in PHP for password verification?

The purpose of using the password_verify() function in PHP is to securely verify a password against a hashed password. This function compares a plain text password with a hashed password to determine if they match, providing a secure way to authenticate users without storing plain text passwords in the database.

// Example code to verify a password using password_verify()

$hashed_password = '$2y$10$Vq2bYRb3qkFjY7nVtZi0UO4Y1s9WtW2DlqXQd3VzRQXtJ1QzKtJr2'; // Hashed password retrieved from the database
$user_input_password = 'password123'; // Plain text password entered by the user

if (password_verify($user_input_password, $hashed_password)) {
    echo 'Password is correct';
} else {
    echo 'Password is incorrect';
}