【发布时间】:2010-10-10 06:09:12
【问题描述】:
我需要在 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';
}
这就是我到目前为止所想到的。我打算用require /config.inc.php将此配置信息导入我的应用程序。
在存储配置数据方面什么对您有用,以及这方面的最佳做法是什么?
【问题讨论】: