我正在尝试让消息在客户输入时显示换行符,但我在每行之间得到/r/n
。我还希望$body .= $_SESSION['username'];
出现在另一行。
我试图使用这个例子:PHP nl2br() basic function来解决,但没有成功。
PHP:
$body .= $_SESSION['username'];
$body .= $message;
$to = $email;
$subject = "copy of your notification";
$headers = "From: noti@r.co.uk\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'Bcc:noti@r.co.uk' . "\r\n";
mail($to,$subject,$body,$headers);
HTML表单:
<form action="notification.php" method="Post" class="rl">
<div>
<label for="message" class="fixedwidth">Message</label>
<textarea name="message" rows="7" cols="40" id="message"></textarea>
</div>
<div class="buttonarea">
<p>
<input type="submit" name="notify" value="Notify"></p>
</div>
</p>
</form>
答案 0 :(得分:0)
您可以尝试使用PHP_EOL
常量:
$body .= $_SESSION['username'].PHP_EOL;