我有PHP mail():函数正在我在我的网站上使用的表单.我现在正在尝试格式化$ body属性,以便在收到后续电子邮件时看起来更好,更有条理.
我已经尝试过了,我已经尝试过
并且都给了我
这是我正在使用的代码片段(我认为这只是语法问题,我做错了):
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;
Run Code Online (Sandbox Code Playgroud)
它只是<br />在我收到的电子邮件中显示为文本.当我使用\n时它是一样的(我假设它实际上是正确的方法).我究竟做错了什么?谢谢.
您必须将\n双引号放在"单引号之间'如果您希望将此序列解释为新行(换行符0x0A)字符
看看这个php文档:
http://php.net/manual/en/language.types.string.php
小智 5
(PHP 4,PHP 5)
$body = 'Brand Name: '.$brandname."\r\n".'Name: '.$firstname.' '.$lastname."\r\n".'Email: '.$email."\r\n".'About the Company:'.$bio;
Run Code Online (Sandbox Code Playgroud)
使用"\r\n"了换行符如上
| 归档时间: |
|
| 查看次数: |
29588 次 |
| 最近记录: |