相关疑难解决方法(0)

在PHP中存储配置变量的最佳方法是什么?

我需要在PHP中存储一堆配置信息.

我考虑过以下......

// Doesn't seem right.
$mysqlPass = 'password'; 

// Seems slightly better.
$config = array(
     'mysql_pass' => 'password'
);

// Seems dangerous having this data accessible by anything. but it can't be
// changed via this method.
define('MYSQL_PASSWORD', 'password'); 

// Don't know if this is such a good idea.
class Config
{
    const static MYSQL_PASSWORD = 'password';
}     
Run Code Online (Sandbox Code Playgroud)

到目前为止,这是我所想到的.我打算将此配置信息导入到我的应用程序中require /config.inc.php.

对于存储配置数据有什么用处,以及有关此问题的最佳做法是什么?

php configuration-files

24
推荐指数
1
解决办法
1万
查看次数

标签 统计

configuration-files ×1

php ×1