What is the recommended approach for handling passwords in PHP instead of using md5?

Using md5 for hashing passwords is not recommended due to its vulnerability to brute force attacks. Instead, it is recommended to use stronger hashing algorithms like bcrypt or Argon2 for securely storing passwords in PHP.

// Hashing a password using bcrypt
$password = "password123";
$hashedPassword = password_hash($password, PASSWORD_BCRYPT);

// Verifying a password using bcrypt
$enteredPassword = "password123";
if (password_verify($enteredPassword, $hashedPassword)) {
    echo "Password is correct!";
} else {
    echo "Password is incorrect!";
}