What are the best practices for encrypting sensitive data like passwords before passing them in PHP?

When handling sensitive data like passwords in PHP, it is crucial to encrypt them before storing or passing them. One of the best practices is to use a strong hashing algorithm like bcrypt with a unique salt for each password. This adds an extra layer of security and helps protect the passwords from being easily compromised.

// Encrypting a password using bcrypt
$password = "secret_password";
$hashed_password = password_hash($password, PASSWORD_BCRYPT);

// Verifying a password
$entered_password = "secret_password";
if (password_verify($entered_password, $hashed_password)) {
    echo "Password is correct";
} else {
    echo "Password is incorrect";
}