"\n"
and "\r\n"
, tested in text message sent by telegram bot, to create line break. Instead of showing line break, underline _
will appear after using them.
How I could printing line feed in telegram message sent by bot?
CODE
$txt = 'با تشکر از عضویت شما، هر روز حدود ساعت 10 شب یک ویدئوی جالب برای شما ارسال خواهد شد.';
$txt .= " \n ";
$txt .= 'Thanks for joining, Every day at almost 18:30 GMT an intersting video will be sent';
Message Demo
Any help will be appreciated.
Switch to Inline buttons Pressing a switch to inline button prompts the user to select a chat, opens it and inserts the bot's username into the input field. You can also pass a query that will be inserted along with the username – this way your users will immediately get some inline results they can share.
Put “\n” inside your string if you want a new line.
There is a better way! The problem is because of URL encodings...
You can use normal PHP text using \n
but by passing it to urlencode
method, as follows:
$txt = urlencode("here is my text.\n and this is a new line \n another new line");
It works for me!
For future visitor just I quote @Dagon answer in comments:
Using %0A
will make line feed in telegram messages
1) If you develop your code in Windows/Linux OS, you can simply use enter in text:
$text = 'test 123
another text';
Thats all!
2) If your code run on Windows/Linux server, you can use PHP_EOL
constant instead of \n
:
$text = 'text 123 '.PHP_EOL.'yet another text';
3) And if you search for an OS independent soloution, you can use %0A
or chr(10)
for this purpose:
$text = 'text 123 '.chr(10).'yet another text';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With