It is not a secret that storing passwords in a clear text is not secure. However, sometimes developers do that to make the site easy for password recovery. There exists a password hashing technique that is used for building the security of passwords. It is called bcrypt. You can use it for protecting the password from different attacks. With it, the password is kept in a bcrypted format. In this snippet, we will demonstrate the way of using the bcrypt technique for hashing passwords. It can be done with the password_hash() function.
<?php
$myPassword = "testpassword123";
echo password_hash($myPassword, PASSWORD_BCRYPT);
?>