What is the purpose of encrypting passwords using md5 in PHP?

Encrypting passwords using md5 in PHP helps to securely store user passwords by converting them into a fixed-length hash value. This hash value is not reversible, meaning the original password cannot be easily obtained from the stored hash. This adds an extra layer of security to protect user data in case of a data breach.

$password = 'password123';
$hashed_password = md5($password);
echo $hashed_password;