简体   繁体   中英

How to print bold text in Heredoc

I have a block of Heredoc for email that I am sending out. In this block I am trying print selected text in bold/strong.

Take the following block of heredoc as an example.

<<<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. In the email it gets displayed as it is with b tags intact.

can someone please show me the way to achieve this as well some basic HTML integration in heredoc.

That is because the email which you are sending does not contain HTML enabled headers.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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