PHP Configuration Array ?

What is PHP configuration array ?

In PHP, a configuration array is a special type of array that is used to store configuration settings for an application or a script. Configuration arrays are typically defined as global variables and are accessed throughout the codebase to retrieve various settings that affect the behavior of the application.


Configuration arrays can be defined in various ways, depending on the specific needs of the application. For example, configuration arrays can be defined as constants, static properties of a class, or as simple global variables. 


Here's an example of a configuration array in PHP:

$config = array(

    'database_host' => 'localhost',

    'database_name' => 'my_database',

    'database_user' => 'my_username',

    'database_password' => 'my_password',

    'debug_mode' => true,

    'log_level' => 'error'

);

In this example, the configuration array stores settings related to a database connection, debug mode, and logging. The settings can be accessed throughout the codebase by referencing the keys of the `$config` array. For example, to retrieve the database name, you would use `$config['database_name']`.

What is $cfg['Servers'] ?

`$cfg['Servers']` is a PHP configuration array used by phpMyAdmin, a popular web-based database management tool, to store the settings for connecting to one or multiple MySQL database servers. 

The `$cfg['Servers']` array contains one or more sub-arrays, where each sub-array represents a separate MySQL server. The sub-array includes various configuration options such as the server hostname, port, username, password, and any additional connection parameters needed for the connection.

Here's an example of how `$cfg['Servers']` may look like:


$cfg['Servers'] = array(

    array(

        'host' => 'localhost',

        'port' => '',

        'user' => 'root',

        'password' => '',

        'auth_type' => 'config',

    ),

    array(

        'host' => 'example.com',

        'port' => '3306',

        'user' => 'myuser',

        'password' => 'mypassword',

        'auth_type' => 'cookie',

    ),

);


In this example, there are two sub-arrays, each representing a separate MySQL server. The first server is running on the same machine as phpMyAdmin and uses the default MySQL port, while the second server is located on a remote machine and uses a non-default port. The authentication method for the first server is "config", which means that phpMyAdmin will use the username and password specified in the configuration array, while the second server uses "cookie" authentication, which means that phpMyAdmin will prompt the user for the login credentials.