如何在fscanf
和$sender_name
之后突破线?现在它只显示$sender_number
作为输出,但当我删除" $sender_name
"他们都在一条线上。
\n
整个PHP代码
$body .= chunk_split(base64_encode($sender_name."\n\r"));
$body .= chunk_split(base64_encode($sender_number."\n\r"));
$body .= chunk_split(base64_encode($sender_message."\n\r"));
答案 0 :(得分:2)
你是base64编码行结尾以及
所以实际输出不会有\ n \ r 试试这个:
$body = $sender_name. "\n";
$body = $sender_number. "\n";
$body = $sender_message. "\n";
编辑: 鉴于您的代码:
.=
在这些行中,您不会附加字符串,而是为其指定新值;使用HashSet<string>
代替赋值运算符
答案 1 :(得分:2)
你也是encondig“\ n \ r”,请务必将换行符放在最后,
$body .= chunk_split(base64_encode($sender_name)) . PHP_EOL;
$body .= chunk_split(base64_encode($sender_number)) . PHP_EOL;
$body .= chunk_split(base64_encode($sender_message)) . PHP_EOL;
如果您使用PHP_EOL
发送电子邮件作为html替换<br />
,请执行以下操作:
$body .= chunk_split(base64_encode($sender_name)) . "<br />";
$body .= chunk_split(base64_encode($sender_number)) . "<br />";
$body .= chunk_split(base64_encode($sender_message)) . "<br />";