2011-05-09 52 views
12

所以我想这卷曲网址:卷曲请求的URL与URL空格..怎么办

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。

我该如何解决这个问题?卷曲只要达到任何空白脱落的字符串的其余部分... :(

我应该提,我不能换用双引号的URL,因为它被张贴的变量。

编辑:hahahahaha wowwwwww brainfart ..感谢球员:?:P

+0

这是另一种替代方案正是这样做的:http://unix.stackexchange.com/questions/86729/any-way-to-encode-the -url合卷曲命令 – 2014-12-05 04:18:05

回答

19

只需使用str_replace函数替换空间

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

也许尝试与%20

0

使用str_replace();函数。更换你" ""%20"

2

我用:

$link = trim($link); 
$link = str_replace (' ', '%20', $link);