如何发送带有多个撇号的电子邮件&;电子邮件正文中的引号


how to send email with multiple Apostrophe & quotation mark in body of email

我有一个电子邮件模板,它由类似的html标签组成

$mail->Body = '<td style="color: #848484; font-size: 14px; font-family: Calibri, 
sans-serif, 'Open Sans'; line-height: 18px; border-collapse: collapse;" 
align="left">Copyright (C) 2016 example All rights reserved.</td>';

现在,如果我将"Open Sans"更改为"Open Sans"字体,则外观会变得混乱;模板中有更多由撇号组成的标签

发送此电子邮件模板而不出现任何错误的最佳方式是什么?

如果用单引号分隔字符串文字,并希望在字符串内容中使用单引号,则需要用反斜杠转义:

$mail->Body = '<td style="color: #848484; font-size: 14px; font-family: Calibri, 
sans-serif, ''Open Sans''; line-height: 18px; border-collapse: collapse;" 
align="left">Copyright (C) 2016 example All rights reserved.</td>';

使用双引号也是一样的:

$mail->Body = "<td style='"color: #848484; font-size: 14px; font-family: Calibri, 
sans-serif, 'Open Sans'; line-height: 18px; border-collapse: collapse;'" 
align='"left'">Copyright (C) 2016 example All rights reserved.</td>";

您应该使用HTML特殊字符HTML特殊字符