复制代码 代码如下:
<?php
//GB2312的Encode
echo urlencode("中文-_. ")."/n"; //%D6%D0%CE%C4-_.+
echo urldecode("%D6%D0%CE%C4-_. ")."/n"; //中文-_.
echo rawurlencode("中文-_. ")."/n"; //%D6%D0%CE%C4-_.%20
echo rawurldecode("%D6%D0%CE%C4-_. ")."/n"; //中文-_.
?>
复制代码 代码如下:
<?php
$url = 'http://s.vevb.com/中文.rar';
echo urlencode(mb_convert_encoding($url, 'utf-8', 'gb2312'))."/n";
echo rawurlencode(mb_convert_encoding($url, 'utf-8', 'gb2312'))."/n";
//http%3A%2F%2Fs.vevb.com%2F%E4%B8%AD%E6%96%87.rar
?>
复制代码 代码如下:
<?php
function parseurl($url="")
{
$url = rawurlencode(mb_convert_encoding($url, 'gb2312', 'utf-8'));
$a = array("%3A", "%2F", "%40");
$b = array(":", "/", "@");
$url = str_replace($a, $b, $url);
return $url;
}
$url="ftp://ud03:password@s.vevb.com/中文/中文.rar";
echo parseurl($url);
//ftp://ud03:password@s.vevb.com/%D6%D0%CE%C4/%D6%D0%CE%C4.rar
?>
新闻热点
疑难解答