How can configuration files be effectively used to manage debugging settings and other environment-specific variables in PHP projects?

When working on PHP projects, it's important to manage debugging settings and environment-specific variables efficiently. One way to achieve this is by using configuration files. These files can store different settings for different environments (such as development, staging, production) and can be easily updated without modifying the code. By loading the appropriate configuration file based on the current environment, you can ensure that your debugging settings and environment-specific variables are properly set.

// Load configuration file based on environment
$environment = 'development'; // Change this to 'staging' or 'production' as needed
$config = include 'config/' . $environment . '.php';

// Use the configuration settings
$debugMode = $config['debug'];
$databaseHost = $config['database']['host'];
$databaseUsername = $config['database']['username'];
$databasePassword = $config['database']['password'];