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

标签 php zend-framework parsing 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.

关于php - 在 Linux 上的 Zend 配置 ini 文件中包含花括号内的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2494303/

相关文章:

php - 如何在 PHP 的应用程序范围内保存数据?

java - 使用 Scanner/Parser/Lexer 进行脚本整理

zend-framework - 曾: parameter collision

php - 使用ajax在表中显示数组数据

json - 从 Itunes API 解包 JSON - IOS App

javascript - 如何解析 GWT 中的日期?

php - 从数据库插入选择框列

PHP,生成带格式的字符串,检查 SQL 数据库?

php - 从 Windows 中在 PHP 中创建 UNIX 安全测试

php - 无法通过 php 连接到 couchbase