Nic*_*ick 8 php ini zend-framework newline
我正在尝试使用PHP/Zend Framework在ini文件中存储多行电子邮件.我的字符串中有新行字符,当我使用Zend_Config_Ini来解析ini文件时,新行字符会返回转义,因此它们会在屏幕上打印出来,而不是换行符.
例:
// ini file
message = Hi {0},\n\nThis is a test message.\nGoodbye!
Run Code Online (Sandbox Code Playgroud)
由Zend_Config_Ini解析为:
Hi {0},\\n\\nThis is a test message.\\nGoodbye!
Run Code Online (Sandbox Code Playgroud)
然后在电子邮件中打印出来:
嗨约翰,\n \n这是一条测试信息.\n再见!
相反,我希望电子邮件看起来像这样:
你好,约翰,
这是一条测试消息.
再见!
有谁知道如何实现这一目标?谢谢!
Pas*_*TIN 12
如何使用双引号围绕您的值,并使用真正的换行符,如下所示:
message = "Hi {0},
This is a test message.
Goodbye!"
Run Code Online (Sandbox Code Playgroud)
例如,使用这部分代码:
$config = new Zend_Config_Ini(APPLICATION_PATH . '/config/application.ini');
var_dump($config->production->testmessage);
die;
Run Code Online (Sandbox Code Playgroud)
随着application.ini包含此:
[production]
testmessage = "this is
a new
message"
Run Code Online (Sandbox Code Playgroud)
我得到了以下输出var_dump:
string(21) "this is
a new
message"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7855 次 |
| 最近记录: |