【问题标题】:best php config / ini class?最好的 php 配置/ini 类?
【发布时间】:2009-07-07 15:40:48
【问题描述】:

我正在寻找 php 中 parse_ini_file() 函数的替代方法。我想要一种简单的方式来存储配置设置,但想要灵活地存储无限级别的多个数组、特殊字符等。有什么想法吗?

【问题讨论】:

  • 您最终选择了 Zend 选项,还是找到了不需要 Zend 的解决方案?
  • 在我正在从事的项目中,我最终编写了自己的基本配置类,但现在我使用 Zend,因为它非常易于使用并且具有一些很好的额外功能(一个用于开发的配置文件/分期/制作等)

标签: php configuration


【解决方案1】:

Zend_Config_Ini 非常适合这个:

$config = new Zend_Config_Ini('/path/to/config.ini', 'staging');

echo $config->database->params->host; // 打印“dev.example.com”

echo $config->database->params->dbname; // 打印“dbname”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-03
    • 1970-01-01
    • 2011-11-26
    • 2012-08-28
    • 1970-01-01
    • 1970-01-01
    • 2019-10-22
    相关资源
    最近更新 更多