php - 在安装 PHP 时设置 MySQL 配置数据

标签 php mysql installscript

我已经为 mysql 表制作了一个安装脚本。我希望用户设置数据库配置。 mysql 的配置作为公共(public)变量硬编码在 PHP 类中。

在安装时创建和存储配置数据的最佳做法是什么?

最佳答案

我建议使用 .ini 文件。示例:

数据库.config.ini:

host = "localhost"
db = "test"
user = "root"
pass = ""

加载配置:

$config = parse_ini_file('database.config.ini');
print_r($config);

/*Array
(
    [host] => "localhost"
    [db] => "test"
    [user] => "root"
    [pass] => ""
)*/

关于php - 在安装 PHP 时设置 MySQL 配置数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13250737/

相关文章:

python - 从mysql生成python中的名称列表

windows-installer - 如果注册表中存在特定键,则中止 Install Shield 安装

php - 无法使用 Twitter V1.1 API 验证用户

PHP:500错误到错误页面

PHP:根据年龄计算生日

InstallShield 响应文件缺少响应

registry - RegDBQueryKey 无法同时列出 32 位和 64 位 key 的 key

php - 如何将 CSS 类添加到 Zend_Form_Element_Select 选项

php - 在打印之前检查 file_get_contents 返回

mysql - SQL 分组平均值