【问题标题】:Reading and writting from an ini file (Config_Lite)从 ini 文件读取和写入 (Config Lite)
【发布时间】:2013-02-13 22:17:58
【问题描述】:

好吧,我已经阅读了一段时间,到目前为止我发现的最佳解决方案是:How to read and write to an ini file with PHP

我已经安装了 pear 包。包含启动课程所需的文件。如图所示: https://github.com/pear/Config_Lite/blob/master/docs/examples

但是我在获取变量时遇到了麻烦。

这是我的ini文件:

[Account]
acct1.UserName = something1
acct1.Password = something2
acct1.Signature = something3
acct1.AppId = something4
# Subject is optional and is required only in case of third party authorization 
acct1.Subject = 

这是我迄今为止尝试过的:

$config = new Config_Lite('$filename');
echo $config->get('Account', 'acct1.UserName');

它不起作用并返回错误。

提前致谢。

【问题讨论】:

标签: php pear ini


【解决方案1】:

您可以使用acct1[UserName]=something1 代替acct1.UserName=something1,然后在PHP 中通过以下代码访问它:

[Account]
acct1[UserName]=something1

$config = new Config_Lite("$filename");
$config_acc = $config -> get('Account','acct1');
echo $config_db['UserName'];

【讨论】:

  • 请在您的答案中添加解释以避免删除
【解决方案2】:
猜你喜欢
  • 2015-09-17
  • 2013-06-01
  • 2012-12-01
  • 2014-09-17
  • 2011-08-07
  • 2010-10-14
  • 1970-01-01
  • 2013-05-21
相关资源
最近更新 更多