所以我正在为我的网站编写邮件表单,我开始工作了。现在我想用cutsom消息来个性化它,但是。。。我不知道如何在变量消息中添加换行符。我试着使用<br />
,但它只是把它打印成一个单词。有什么想法吗?
附言:我可能完全错了,可以完全改变信息中的内容,我只想理解这个概念。
<?php
$message =
"You recieved mail from $mail with a question." .
"The question contains the following:" .
"$_POST['message'];";
?>
编辑:@Ben Pearl Kahan的回答对我有用!谢谢你的回答!
在双引号中,'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']"
不是正确的级联;您应该处理字符串外部的数组变量:
"text ".$_POST["message"]." more text"
或者使用大括号(注意:只有当字符串被包含在双引号中时,这才有效):
"text {$_POST["message"]} more text"
对于换行符,PHP为"''n"(请参阅双引号字符串)和PHP_EOL。
<?php
$message = "You recieved mail from $mail with a question'nThe question contains the following:'n{$_POST['message']}";
?>