I am trying to store a multiple line e-mail in an ini file using PHP/Zend Framework. My string has new lines characters in it, and when I use Zend_Config_Ini to parse the ini file, the new line characters come back escaped, so they are printed out on screen, instead of a line feed.
Example:
// ini file
message = Hi {0},\n\nThis is a test message.\nGoodbye!
is parsed by Zend_Config_Ini as:
Hi {0},\\n\\nThis is a test message.\\nGoodbye!
which then is printed out in the email as:
Instead I want the e-mail to look like this:
Does anybody know how to achieve this? Thanks!
What about using double-quotes arround your values, and using real newlines, like this :
message = "Hi {0},
This is a test message.
Goodbye!"
As an example, using this portion of code :
$config = new Zend_Config_Ini(APPLICATION_PATH . '/config/application.ini');
var_dump($config->production->testmessage);
die;
With application.ini
containing this :
[production]
testmessage = "this is
a new
message"
I get the following output from my var_dump
:
string(21) "this is
a new
message"
Use php constant: PHP_EOL
message = "Hi {0}," PHP_EOL PHP_EOL "This is a test message." PHP_EOL "Goodbye!"
Note that the constant PHP_EOL in application.ini must appear outside of the quotation marks. Otherwise it'll be interpreted as a literal.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.