PHP new line break in emails

后端 未结 8 1777
闹比i
闹比i 2020-11-27 20:35

I have the following code:

$message = \"Good news! The item# $item_number on which you placed a bid of \\$ $bid_price is now available for purchase at your b         


        
8条回答
  •  执笔经年
    2020-11-27 21:31

    I know this is an old question but anyway it might help someone.

    I tend to use PHP_EOL for this purposes (due to cross-platform compatibility).

    echo "line 1".PHP_EOL."line 2".PHP_EOL;
    

    If you're planning to show the result in a browser then you have to use "
    "
    .

    EDIT: since your exact question is about emails, things are a bit different. For pure text emails see Brendan Bullen's accepted answer. For HTML emails you simply use HTML formatting.

提交回复
热议问题