$str="plus2net.com";
$str_hash=password_hash($str,PASSWORD_DEFAULT);
//echo $str_hash;
if(password_verify($str,$str_hash)){
echo " Matching ";
}else{
echo " Not matching ";
}
Output is
Matching
Syntax
password_verify('$entered_string',$hash_string);
Parameter | DESCRIPTION |
---|---|
$entered_string | Required : Input password string ( user entered ) |
$hash_string | Required : Hash created by password_hash(). |
$str="plus2net.com";
$str_crypt_hash = crypt($str);
///////////
if(password_verify('plus2net.com',$str_crypt_hash)){
echo " Matching ";
}else{
echo " Not matching ";
}
Output is
Matching
$password = "secure123";
$hash = password_hash($password, PASSWORD_DEFAULT);
if (password_verify("secure123", $hash)) {
echo "Password is correct!";
} else {
echo "Password is incorrect!";
}
$password = "secure123";
$hash = password_hash($password, PASSWORD_DEFAULT);
if (password_verify("wrong_password", $hash)) {
echo "Password is correct!";
} else {
echo "Password is incorrect!";
}
$hash = password_hash("mypassword", PASSWORD_DEFAULT);
if (password_verify("mypassword", $hash)) {
if (password_needs_rehash($hash, PASSWORD_DEFAULT)) {
$newHash = password_hash("mypassword", PASSWORD_DEFAULT);
echo "Password rehashed!";
}
}
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.