What are the best practices for securely handling passwords in PHP, such as encryption methods like md5()?

When storing passwords in PHP, it is important to securely hash them using a strong hashing algorithm like bcrypt. Using outdated methods like md5() or sha1() is not recommended due to their vulnerability to brute force attacks. By using bcrypt, you can safely store passwords in your database without compromising the security of your users' information.

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

// Verifying a password
$enteredPassword = "mySecurePassword";
if (password_verify($enteredPassword, $hashedPassword)) {
    echo "Password is valid!";
} else {
    echo "Invalid password!";
}