What are some potential pitfalls of using global arrays for configuration in PHP?

Using global arrays for configuration in PHP can lead to potential issues such as lack of encapsulation, making it difficult to track changes and manage dependencies. To avoid these pitfalls, it is recommended to use a more structured approach like using a configuration class or a configuration file.

class Config {
    public static $config = [
        'database' => [
            'host' => 'localhost',
            'username' => 'root',
            'password' => 'password',
            'database' => 'my_database'
        ],
        'app' => [
            'name' => 'MyApp',
            'debug' => true
        ]
    ];
}

// Access configuration values
echo Config::$config['database']['host']; // Output: localhost
echo Config::$config['app']['name']; // Output: MyApp