php urlencode

如果要使用UTF-8的Encode,有两种方法:
一、将文件存为UTF-8文件,直接使用urlencode、rawurlencode即可。
二、使用mb_convert_encoding函数。

Php代码
  1. <?php  
  2. $url = 'http://ud03.kinoko.name/中文.rar';  
  3. echo urlencode(mb_convert_encoding($url'utf-8''gb2312'))."\n";  
  4. echo rawurlencode(mb_convert_encoding($url'utf-8''gb2312'))."\n";  
  5. //http%3A%2F%2Fud03.kinoko.name%2F%E4%B8%AD%E6%96%87.rar  
  6. ?> 
原文地址:https://www.cnblogs.com/macula7/p/1960379.html