所以我正在为我的网站制作一个邮件表格,我让我工作了。现在我想用一个cutom消息来个性化它但是......我不知道如何在变量消息中添加换行符。我尝试使用<br />
,但只是将其打印出来。那么任何想法都是?
P.S。我可能完全错了,可以完全改变我想要理解这个概念的信息。
<?php
$message =
"You recieved mail from $mail with a question." .
"The question contains the following:" .
"$_POST['message'];";
?>
编辑: @Ben Pearl Kahan回答给我工作!谢谢你的答案!
答案 0 :(得分:0)
在双引号中,\r\n
将是一个新行。
示例:
<?php
$message =
"You recieved mail from $mail with a question.\r\n" .
"The question contains the following:\r\n" .
$_POST['message'];
?>
仅供参考,"$_POST['message']"
连接不正确;你应该处理数组变量 outside 字符串:
"text ".$_POST["message"]." more text"
或使用大括号(注意:只有当您的字符串包含在双引号中时才会有效):
"text {$_POST["message"]} more text"
答案 1 :(得分:0)
对于换行符,PHP为&#34; \ n&#34; (see double quote strings)和PHP_EOL。
<?php
$message = "You recieved mail from $mail with a question\nThe question contains the following:\n{$_POST['message']}";
?>