Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php &引用;";这封信并没有发送到电报机器人_Php_Telegram Bot - Fatal编程技术网

Php &引用;";这封信并没有发送到电报机器人

Php &引用;";这封信并没有发送到电报机器人,php,telegram-bot,Php,Telegram Bot,有史以来最奇怪的问题 我正在尝试在php上创建一个电报机器人 当我试图发送到电报bot'H(在H字母前加空格,大写)时,它不工作!未收到消息 $text = ' H'; file_get_contents($website."/sendMessage?chat_id=".$chatId."&text=".$text); 只有“H”(没有空格)时结束。它起作用了 发生了什么事 您需要在url中转义文本: file_get_contents($website."/sendMessage?c

有史以来最奇怪的问题 我正在尝试在php上创建一个电报机器人

当我试图发送到电报bot'H(在H字母前加空格,大写)时,它不工作!未收到消息

$text = ' H';
file_get_contents($website."/sendMessage?chat_id=".$chatId."&text=".$text);
只有“H”(没有空格)时结束。它起作用了


发生了什么事

您需要在url中转义文本:

file_get_contents($website."/sendMessage?chat_id=".$chatId."&text=".urlencode($text));

试试urlencode()。。。谢谢抱歉,这个愚蠢的问题,但为什么它只发生在H字母上呢?它的发生不是因为H字母,而是因为字母前面的空格。空间将被编码为
%20
。我明白了。奇怪的是,当我把一个H字母改成其他字母时,它就起作用了)无论如何,谢谢!在它之前没有空间?或者
$text
中的任何其他特殊字符?'R'发送ok,'H'不