How can PHP developers securely include sensitive information, such as email addresses, in a text file without displaying them?
To securely include sensitive information, such as email addresses, in a text file without displaying them, PHP developers can store the information in a separate configuration file outside the web root directory. This ensures that the sensitive information is not accessible via a direct URL. Then, the PHP script can include the configuration file to access the sensitive data without exposing it to the public.
// config.php (outside web root directory)
<?php
$emails = array(
'email1@example.com',
'email2@example.com',
'email3@example.com'
);
?>
// index.php (inside web root directory)
<?php
include('../config.php');
foreach($emails as $email) {
echo $email . "<br>";
}
?>