在 WhatsApp 消息中创建换行符

2022-08-30 17:20:42

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

什么按钮.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>

如何添加换行符:

我试过 、 、 和 ,但它只是显示为文本。\n\r\nPHP_EOL%0D%0A


答案 1

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

use this %0a


link =`whatsapp://send?text=%0a‎Hello%0aWorld`;

如果要发送一些包含换行符的文本的网址链接

var encodedURL = encodeURIComponent(some_url);
link =`whatsapp://send?text=${encodedURL}%0a‎Hello%0aWorld`;

现在将此链接嵌入到锚点标记中

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

答案 2

要在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+");

推荐