我们有一个如下的url:
我想要做的事情是(是的,在url周围有空格):
http://site.s3.amazonaws.com/images/some image @name.jpg
,它在$string
中。我想要做的事情是(是的,在url周围有空格):
$string = urlencode(trim($string));
$string_data = file_get_contents($string);
我得到的结果(@也被替换):
file_get_contents(http%3A%2F%2Fsite.s3.amazonaws.com%2Fimages%2Fsome+image+@name.jpg)[function.file-get-contents]: failed to open stream: No such file or directory
如果你将http://site.s3.amazonaws.com/images/some image @name.jpg
复制/粘贴到浏览器地址栏中,图片将会打开。
问题出在哪里,如何解决?