cURL在URL中请求带有空格的网址..该怎么办 [英] cURL requesting URL with whitespaces in URL.. What to do

查看:2794
本文介绍了cURL在URL中请求带有空格的网址..该怎么办的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想卷曲此网址:

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

网址编码为:

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

curl需要它被解码成一个合适的URL明显。

However, curl needs it to be decoded into a proper URL obviously.

我如何解决这个问题? cURL在字符串的其余部分一旦到达任何空格就会删除...:(

How do i get around this problem? cURL drops off the rest of the string as soon as it reaches any whitespace... :(

我应该提到我不能用双引号括起URL是张贴的变量。

I should mention I can't wrap the URL with double quotes as it is a variable being posted.

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

hahahahaha wowwwwww brainfart.. thanks guys :P

推荐答案

只要使用str_replace。

Just use str_replace.

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

这篇关于cURL在URL中请求带有空格的网址..该怎么办的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆