简体   繁体   English

如何在Heredoc中打印粗体文本

[英]How to print bold text in Heredoc

I have a block of Heredoc for email that I am sending out. 我有一个Heredoc块,用于发送我的电子邮件。 In this block I am trying print selected text in bold/strong. 在此块中,我尝试以粗体/强行打印所选文本。

Take the following block of heredoc as an example. 以以下Heredoc块为例。

<<<ENDINGTEXT

    Example text

    more text

    <b>This in bold</b>

ENDINGTEXT;

When I send above out as an email. 当我以电子邮件形式发送出去时。 The "b" tags do not convert the text within it to be bold. “ b”标签不会将其中的文本转换为粗体。 In the email it gets displayed as it is with b tags intact. 在电子邮件中,它会按原样显示并带有b标签。

can someone please show me the way to achieve this as well some basic HTML integration in heredoc. 有人可以告诉我实现此目标的方法以及Heredoc中的一些基本HTML集成吗?

That is because the email which you are sending does not contain HTML enabled headers. 这是因为您发送的电子邮件不包含启用HTML标题。

You need to set the headers like this. 您需要像这样设置标题。

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

For a detailed example, see the PHP Manual here 有关详细示例,请参见here的PHP手册here

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM