怎么把URL的空格转变为字符?

例如我要读一个文件
readfile("http://localhost/$r1/$r2.txt");
而其中的变量是r2,r1在有空格的时候,就会读不了,应该用什么函数?
---------------------------------------------------------------

urlencode

readfile("http://localhost/".urlencode($r1)."/".urlencode($r2).".txt");

Published At
Categories with Web编程
comments powered by Disqus