在 Linux 上的 Zend 配置 ini 文件中包含大括号内的变量

发布于 2024-08-26 20:41:09 字数 1430 浏览 11 评论 0原文

我试图通过用花括号括住一个变量来将其包含在 .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"}".

是否有为所有平台解决此问题的更好方法?谢谢你的帮助,

戴夫

I am trying to include a variable in a .ini file setting by surrounding it with curly braces, and Zend is complaining that it cannot parse it properly on Linux. It works properly on Windows, though:

welcome_message = Welcome, {0}.

This is the error that is being thrown on 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

We are able to get the error to go away on Linux if we surround the braces with quotes, but that seems like a strange solution:

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

Is there a better way to solve this issue for all platforms? Thanks for your help,

Dave

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍暮颜 2024-09-02 20:41:09

在引号之间包含整个消息怎么样?

有点像这样:

welcome_message = "Welcome, {0}."

Quoting the documentation of [`parse_ini_file`][1] *(which `Zend_Config_Ini` might use)* :

注意:如果ini文件中的值
包含任何非字母数字
需要包含在其中的字符
双引号 (")。

并且,还有(强调我的)

注意:有保留字
不得用作 ini 的键
文件。
其中包括:nullyesno

价值观
nullnofalse 结果为 "", yes
true 结果为“1”
人物
不得使用 {}|&~![()^"

键中的任何位置并且
值中有特殊含义

What about having the whole message between quotes ?

A bit like this :

welcome_message = "Welcome, {0}."

Quoting the documentation of [`parse_ini_file`][1] *(which `Zend_Config_Ini` might use)* :

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

And, also (emphasis mine) :

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
.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文