在$ body的PHP邮件功能中创建一个新行 [英] Creating A New Line In $body Of PHP Mail Function
问题描述
我有PHP mail():函数为我在我的网站上使用的表单工作。我正在尝试格式化$ body属性,以便在收到后续电子邮件时看起来更好,更有条理。
I've got the PHP mail(): function working for a form I'm using on my site. I am now trying to format the $body attribute to look nicer and more organized when I receive the subsequent e-mail.
我已经尝试过\\我试过了
并且都给了我
I've tried \n and I've tried
and both give me
这是我正在使用的代码片段(我认为这只是我正在做的语法问题错误):
Here's the snippet of the code that I'm working with (I think it's just a matter of syntax that I'm doing wrong):
if(!empty($brandname) && !empty($firstname) && !empty($lastname) && !empty($email) && !empty($goals) && !empty($bio)){
$to = 'test@test.com';
$subject = 'Submission Form';
$body = 'Brand Name: '.$brandname.'<br />Name: '.$firstname.' '.$lastname.'<br />Email: '.$email.'<br />About the Company:'.$bio;
$headers = 'From: '.$email;
只显示< br />
作为我收到的电子邮件中的文本。当我使用\(我假设实际上是正确的方式)时,这是一样的。我究竟做错了什么?谢谢。
It's just displayed the <br />
as text in the e-mail I receive. It was the same when I used \n (which I'm assuming is actually the right way to do it). What am I doing wrong? Thanks.
推荐答案
您必须将双引号放在双引号之间,而不是单引号之间。解释为新行(换行0x0A)字符
You must place \n in double quotes " not between single quotes ' If you want that this sequence would be interpreted as a new line (line feed 0x0A) character
查看此php文档:
< a href =http://php.net/manual/en/language.types.string.php> http://php.net/manual/en/language.types.string.php
这篇关于在$ body的PHP邮件功能中创建一个新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!