I use getimagesize
to judge an image height and size.
When a url has space, the getimagesize
echo's an error. I've tried using urlencode()
to transfer all the url address, it still returns an error. I noticed that if I just change the space into %20
, getimagesize
runs ok.
I have no idea why?
I also tired to use $newurl = preg_replace(' ', '%20', $url);
It echo'ed :
Warning: preg_replace() [function.preg-replace]: Empty regular expression
So how to preg_replace
correctly. And is there a way to transfer the url correctly with getimagesize
so that it passes all possible test cases.
Thanks
you should use str_replace(' ', "%20", $url)
instead of preg_replace(' ', '%20', $url);