What potential security risks are associated with storing user credentials in plain text within a PHP script?

Storing user credentials in plain text within a PHP script poses a significant security risk as anyone with access to the script can easily view and misuse the sensitive information. To mitigate this risk, it is recommended to store user credentials securely by hashing passwords before storing them in a database.

// Hashing the password before storing it in the database
$password = 'user_password';
$hashed_password = password_hash($password, PASSWORD_DEFAULT);

// Storing the hashed password in the database
// Example query: INSERT INTO users (username, password) VALUES ('user', '$hashed_password');