使用mail();添加一个不存在的加法返回中断


using mail(); adds an addition return break that is not there

问题是在我使用mail函数后,它添加了一个不存在的回车符。代码如下:

    $lesujet = "testing ...";
    $letexts = "a bunch of text       
    there is a return break here
    another return break as you see";
    mail("myemail@gmail.com",$lesujet,$letexts,$headers);

这就是电子邮件的样子:一堆文本

这里有返程休息

另一个返回中断,如您所见

尝试使用函数str_ireplace删除换行符:

$letexts = str_ireplace(array("'r","'n"),array('',''),$letexts);

这是因为当您初始化多行中的字符串时,它实际上会在每行之后添加一个字符串,''r''n请尝试:

$letexts = "a bunch of text "
. "there is a return break here "
. "another return break as you see ";

对于多行字符串init,请查看此SO线程,了解有关多行字符串最佳实践的讨论。