好吧所以我已经阅读了一段时间,到目前为止我找到的最佳解决方案是:How to read and write to an ini file with PHP
我已经安装了梨包。包括发起课程所需的文件。如图所示: 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');
它无效并返回错误。
先谢谢。
答案 0 :(得分: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'];
答案 1 :(得分:-3)