php – 如何在电报消息中生成新行字符?

当我将从
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.

最佳答案 嗯,这很容易!我只需要在网址中编码消息,但没有人告诉我这样做!

$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.
点赞