What are the potential security risks of implementing password protection using .htaccess in PHP?

One potential security risk of implementing password protection using .htaccess in PHP is that the passwords are stored in plaintext in the .htpasswd file, making them vulnerable to unauthorized access if the file is compromised. To mitigate this risk, it is recommended to hash the passwords before storing them in the .htpasswd file.

$password = 'password123';
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
echo $hashed_password;