Php urlencode()不起作用

Php urlencode()不起作用,php,urlencode,Php,Urlencode,我有这样一个URL: http://x.x.x.x/feedsms?to=$groupName&text=$content" F: user@domain.com S: Veeam Repoting B: Target: y.y.y.y, Status: Error, Time: 8/22/2015 3:05:30 PM 当我调用此url时,它会发送短信。 由于空格和特殊字符,我使用了file\u get\u contents()读取SMS内容和urlencode(): $url =

我有这样一个URL:

http://x.x.x.x/feedsms?to=$groupName&text=$content"
F: user@domain.com S: Veeam Repoting B: Target: y.y.y.y, Status: Error, Time: 8/22/2015 3:05:30 PM
当我调用此url时,它会发送短信。 由于空格和特殊字符,我使用了
file\u get\u contents()
读取SMS内容和
urlencode()

$url = urlencode("http://x.x.x.x/feedsms?to=$groupName&text=$content");
$urlContent = file_get_contents($url);
$content
是这样的:

http://x.x.x.x/feedsms?to=$groupName&text=$content"
F: user@domain.com S: Veeam Repoting B: Target: y.y.y.y, Status: Error, Time: 8/22/2015 3:05:30 PM
但我无法调用url:

file_get_contents(): failed to open stream: No such file or directory ... 
我还使用了
rawurlencode()
,但没有任何更改。

应该被用来编码一个字符串,就像文档所说的那样,在URL的查询部分中使用。您不应该在整个URL上使用它,而应该只对每个应该编码的参数使用它,在您的例子中是
$groupName
$content
。像这样的事情应该可以做到:

$url = "http://x.x.x.x/feedsms?to=" . urlencode($groupName) . "&text=" . urlencode($content);