cURL使用URL中的空格请求URL ..怎么做

Att*_*cus 24 php parsing curl communication

所以我试图卷曲这个网址:

http://images.fastcompany.com/upload/Screen shot 2011-04-28 at 8.13.21 PM.png

URL编码它读作:

http%3A%2F%2Fimages.fastcompany.com%2Fupload%2FScreen+shot+2011-04-28+at+8.13.21+PM.png

但是,curl显然需要将其解码为正确的URL.

我该如何解决这个问题?一旦到达任何空格,cURL就会掉落其余的字符串...... :(

我应该提到我不能用双引号包装URL,因为它是一个被发布的变量.

编辑:hahahahaha wowwwwww brainfart ..谢谢你们:P

Kan*_*ann 26

只需使用str_replace.

echo str_replace ( ' ', '%20', 'http://images.fastcompany.com/upload/Screen shot 2011-04-28 at 8.13.21 PM.png' );
Run Code Online (Sandbox Code Playgroud)


Dre*_*rew 13

也许尝试用空格替换%20


Hoà*_*gtt 6

我用:

$link = trim($link);
$link = str_replace ( ' ', '%20', $link);
Run Code Online (Sandbox Code Playgroud)