How can SHA and MD5 be implemented for password hashing in PHP?

When storing passwords in a database, it is important to hash them to protect user data. One way to do this in PHP is by using the SHA or MD5 hashing algorithms. By hashing passwords before storing them, even if the database is compromised, the actual passwords are not exposed. Here is an example of how to implement SHA and MD5 for password hashing in PHP:

// Using SHA-256 for password hashing
$password = "password123";
$hashed_password = hash('sha256', $password);

// Using MD5 for password hashing
$password = "password123";
$hashed_password = md5($password);