Php 在WhatsApp消息中创建换行符

Php 在WhatsApp消息中创建换行符,php,jquery,html,whatsapp,Php,Jquery,Html,Whatsapp,我一直在使用WhatsApp共享消息: whatsapp-button.js $_u.="Product Name:".$_productName."\n"; $_u.="Sku:".$_productSku."\n"; <a href="whatsapp://send" data-text="<?php echo nl2br($_u); ?>" data-href="" class="wa_btn <?php echo $buttonsize; ?>" sty

我一直在使用WhatsApp共享消息:

whatsapp-button.js

$_u.="Product Name:".$_productName."\n";

$_u.="Sku:".$_productSku."\n";

<a href="whatsapp://send" data-text="<?php echo nl2br($_u); ?>" data-href="" class="wa_btn <?php echo $buttonsize; ?>" style="display:none">Share</a>
$\u.=“产品名称:”.$\u产品名称。“\n”;
$\u.=“Sku:”.$\u产品Sku.\n”;
如何添加换行符:


我尝试过
\n
\r\n
PHP\u EOL
%0D%0A
,但它只显示为文本。

我得到了一个可行的解决方案:

HTML:

有一种解决方案基本上是使用:

whatsappMessage = window.encodeURIComponent(whatsappMessage)

如果只发送包含换行符的文本

use this %0a


link =`whatsapp://send?text=%0a‎Hello%0aWorld`;
如果要发送包含换行符的文本的url链接

var encodedURL = encodeURIComponent(some_url);
link =`whatsapp://send?text=${encodedURL}%0a‎Hello%0aWorld`;
现在将此链接嵌入锚标记中

<a href=link> Click here! </a>

要在WhatsApp中创建换行符,可以使用以下命令。它工作正常,我正在使用它:

use `%0a`
例如:

smsContain = "*Greetings from  " + cname + " ,%0a %0aM/s. " + txtName.Text + " %0a %0aYour Bill for Advertisement is generated ; %0a %0aBill Date  :-  " + DateTime.ParseExact(dateTimePicker1.Text, "dd/MM/yyyy", null).ToString("dd/MM/yyyy") + " %0a %0aBill no  :-  " + lblBillNo.Text + "  %0a %0aBilling Amount of Rs.  " + lblNet_Amt.Text + " %0a %0aAdvertisement Published in  " + news + " in " + Edi + "  edition,%0a %0aReleased Date : " + DateTime.ParseExact(DateTime.Parse(dt).ToShortDateString(), "dd/MM/yyyy", null).ToString("dd/MM/yyyy") + ".%0a %0aPlease find the Bill attached below, and request you to please  release the payment ASAP. %0a %0a %0aAny descripancy in regards to this Bill to reported to us immediately.%0a %0a %0aAlways at your Service....* ";
                smsContain = smsContain.Replace("&", "+%26+");

将\n替换为\r\n;)尝试使用:
PHP\u EOL
而不是
\n
。这对你有用吗?你确定你没有把a标签弄乱吗<代码>“Url:尝试
%0D
(回车)如果尝试使用PHP\u EOL,也不要使用nl2br()!
use `%0a`
smsContain = "*Greetings from  " + cname + " ,%0a %0aM/s. " + txtName.Text + " %0a %0aYour Bill for Advertisement is generated ; %0a %0aBill Date  :-  " + DateTime.ParseExact(dateTimePicker1.Text, "dd/MM/yyyy", null).ToString("dd/MM/yyyy") + " %0a %0aBill no  :-  " + lblBillNo.Text + "  %0a %0aBilling Amount of Rs.  " + lblNet_Amt.Text + " %0a %0aAdvertisement Published in  " + news + " in " + Edi + "  edition,%0a %0aReleased Date : " + DateTime.ParseExact(DateTime.Parse(dt).ToShortDateString(), "dd/MM/yyyy", null).ToString("dd/MM/yyyy") + ".%0a %0aPlease find the Bill attached below, and request you to please  release the payment ASAP. %0a %0a %0aAny descripancy in regards to this Bill to reported to us immediately.%0a %0a %0aAlways at your Service....* ";
                smsContain = smsContain.Replace("&", "+%26+");