Is it recommended to store passwords in a database as plain text or should they be hashed for security purposes?

It is highly recommended to hash passwords before storing them in a database for security purposes. Storing passwords as plain text leaves them vulnerable to unauthorized access in case of a data breach. Hashing passwords adds an extra layer of security by converting the password into a unique string of characters that cannot be easily reversed.

$password = "password123";
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// Store $hashed_password in the database