PHP password_verify() Function
PHP Password Hashing Algorithms
The password_verify() function is used to verify whether a password matches a hash value.
PHP Version Requirements: PHP 5 >= 5.5.0, PHP 7
Syntax
bool password_verify ( string $password , string $hash )
Parameter Description:
- password: The user's password.
- hash: Apassword_hash()hash value created by.
Return Value
If the password and hash value match, it returns TRUE; otherwise, it returns FALSE.
Example
password_verify() Usage
//To know where the following characters come from, see the example of password_hash().
$hash = '$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq';
if (password_verify('rasmuslerdorf', $hash)) {
echo 'Password is valid!';
} else {
echo 'Invalid password.';
}
The output result is:
Password is valid!Other Extensions