Stop using `global` in PHP

后端 未结 6 2039
醉梦人生
醉梦人生 2020-11-22 03:45

I have a config.php that is included to each page. In config I create an array that looks something like:

$config = array();
$config[\'site_name\         


        
6条回答
  •  情书的邮戳
    2020-11-22 04:24

    config.php

     'value',
        'key2' => array( 'value', 'can be an', 'array' ),
        'database' => array( "username" => "root", "password" => "root")
                         )
        );
    config::set( 'my_config', 'the value' );
    ?>
    

    config.usage.php

     the config value for password is ' . $database_credentials['password'];
    
    function additionalFunctionality($database_credentials)
    {
        echo '
    the config value for password is ' . $database_credentials['password']; } ?>

    config.usage.too.php

    
    

提交回复
热议问题