What are potential security risks associated with including a config.php file in each script in a PHP application?
Including a config.php file in each script in a PHP application can lead to security risks such as exposing sensitive information like database credentials. To mitigate this risk, it's recommended to move the configuration settings to a single, centralized location outside of the web root directory and include it in each script as needed.
// config.php
<?php
define('DB_HOST', 'localhost');
define('DB_USER', 'username');
define('DB_PASS', 'password');
define('DB_NAME', 'database');
// script.php
<?php
require_once('../config.php');
// Your script code here