Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个应用程序发送包含以下内容的电子邮件..
$message= "Hi, some_content \n some_content_on_new_line".
我希望 some_content_on_new_line 在电子邮件的换行上,但是在发送电子邮件时,“\n”不会插入换行符。相反,它显示为反斜杠,后跟“n”。我怎样才能防止这种情况?这是我的电子邮件配置。
mail($to, $subject, $message, $headers)
如果\n显示在电子邮件内容中,那么问题很可能是使用单引号来定义字符串文字。
\n
$message= 'Hi, some_content \n some_content_on_new_line'; // this will show the \n $message= "Hi, some_content \n some_content_on_new_line"; // this will interpolate the newline properly