What are common methods used by PHP developers to protect sensitive information in scripts?

PHP developers commonly protect sensitive information in scripts by using environment variables, storing credentials in a separate configuration file, or encrypting the sensitive data. One common method is to store sensitive information in environment variables and access them in the script using the getenv() function.

$db_host = getenv('DB_HOST');
$db_user = getenv('DB_USER');
$db_pass = getenv('DB_PASS');
$db_name = getenv('DB_NAME');

// Connect to the database using the sensitive information
$conn = new mysqli($db_host, $db_user, $db_pass, $db_name);