我正在PHP端为WhatsApp编写动态消息。但是当我发送消息时,无法添加新的换行符。我已经尝试了以下代码内的内容,但不适合我的情况:%0D %0a n rn %0D% 0a
。e第一行n第二行%0a第三行rn第四行;br;第五行
我试过了PHP_EQL及其工作
第一行".PHP_EQL."第二行";
<输出/strong>
第一行
第二行
由于您正在发布页面,因此您需要使用nl2br()插入HTML,而不是使用break()。此函数将在找到n的地方插入换行符示例
<?php
echo nl2br("This is first line and.n this is the second line.");
?>
输出strong>
这是第一行
这是第二行
所以HTML OUT就像
This is first line and <br/>this is the second line
"n"-应该可以如$message .= "Enter 'menu' to return to main menu n"; $this->whatsAppService->sendTextMessage($phoneNumber, $message);