如何在电报消息中生成换行符?

Sta*_*ler 5 php telegram

当我将从 mysql 数据库读取的数据发送给电报用户时,用户会得到下划线等而不是换行符。所以这样我就无法正确格式化消息文本。

如何格式化具有 4 个或更多可能答案的问题的电报消息?

还有什么是我不期望的改变?顺便说一下,我发送的是非英文字符。

$qsBody = $rowQuestion['body']; // This is what I read from database that contains some new line characters
$strReply = $qsBody;
$strSendMethod = "SendMessage?chat_id=$ChatId&text='$strReply'";
file_get_contents( BOT_TARGET_ADDRESS . $strSendMethod );
// The message received by user contains _ instead of new line.
Run Code Online (Sandbox Code Playgroud)

Sta*_*ler 3

嗯,这很容易!我只需要在 url 中对消息进行编码。

$qsBody = $rowQuestion['body']; // This is what I read from database that contains some new line characters
$strReply = $qsBody;
$strReply = urlencode($strReply ); // encode message
$strSendMethod = "SendMessage?chat_id=$ChatId&text='$strReply'";
file_get_contents( BOT_TARGET_ADDRESS . $strSendMethod );
// The message received by user contains _ instead of new line.
Run Code Online (Sandbox Code Playgroud)