开发者

Including variables inside curly braces in a Zend config ini file on Linux

开发者 https://www.devze.com 2022-12-23 23:49 出处:网络
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:

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 t开发者_运维知识库he 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


What about having the whole message between quotes ?

A bit like this :

welcome_message = "Welcome, {0}."


Quoting the documentation of parse_ini_file (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.

0

精彩评论

暂无评论...
验证码 换一张
取 消