What are the best practices for securing sensitive information, such as passwords, in PHP scripts?

To secure sensitive information, such as passwords, in PHP scripts, it is recommended to use secure hashing algorithms like bcrypt to store passwords securely. Additionally, it is important to avoid hardcoding sensitive information directly in the script and instead use environment variables or configuration files outside of the web root to store them.

// Example of securely hashing and storing a password using bcrypt

$password = 'mySecurePassword';

// Hash the password using bcrypt
$hashedPassword = password_hash($password, PASSWORD_BCRYPT);

// Store the hashed password securely in a database