微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – 在Linux上的Zend config ini文件中包含大括号内的变量

我试图通过用大括号括起来在.ini文件设置中包含一个变量,并且Zend抱怨它无法在Linux上正确解析它.它可以在Windows上正常工作:

welcome_message = Welcome, {0}.

这是Linux上抛出的错误

:  Uncaught exception 'Zend_Config_Exception' with message 'Error parsing /var/www/html/portal/application/configs/language/messages.ini on line 10
' in /usr/local/zend/share/ZendFramework/library/Zend/Config/Ini.PHP:181
Stack trace:
0 /usr/local/zend/share/ZendFramework/library/Zend/Config/Ini.PHP(201): Zend_Config_Ini->_parseIniFile('/var/www/html/p...')
1 /usr/local/zend/share/ZendFramework/library/Zend/Config/Ini.PHP(125): Zend_Config_Ini->_loadIniFile('/var/www/html/p...')
2 /var/www/html/portal/library/Ingrain/Language/Base.PHP(49): Zend_Config_Ini->__construct('/var/www/html/p...', NULL)
3 /var/www/html/portal/library/Ingrain/Language/Base.PHP(23): Ingrain_Language_Base->setConfig('messages.ini', NULL, NULL)
4 /var/www/html/portal/library/Ingrain/Language/Messages.PHP(7): Ingrain_Language_Base->__construct('messages.ini', NULL, NULL, NULL)
5 /var/www/html/portal/library/Ingrain/Helper/Language.PHP(38): Ingrain_Language_Messages->__construct()
6 /usr/local/zend/share/ZendFramework/library/Zend/Contr in

如果我们用引号括起括号,我们就可以在Linux上消除错误,但这似乎是一个奇怪的解决方案:

welcome_message = Welcome, "{"0"}".

有没有更好的方法解决所有平台的这个问题?谢谢你的帮助,

戴夫

解决方法:

如何在引号之间传递整个消息?

有点像这样:

welcome_message = "Welcome, {0}."

引用parse_ini_file(Zend_Config_Ini可能使用的)的文档:

Note: If a value in the ini file
contains any non-alphanumeric
characters it needs to be enclosed in
double-quotes (").

而且,(强调我的):

Note: There are reserved words which
must not be used as keys for ini
files.
These include: null, yes, no,
true, false, on, off, none.
Values
null, no and false results in "", yes
and true results in "1".
Characters
{}|&~![()^"
must not be used
anywhere in the key and have a
special meaning in the value
.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐