This article mainly introduces the PHP processing with Chinese URL method, involving PHP code conversion related operation skills, with a certain reference value, the need for friends can refer to the next
The example in this article describes how PHP handles a Chinese URL. Share to everyone for your reference, as follows:
IE6 hyperlinks there will be problems when there is Chinese, the evil IE6 ah. PHP makes the built-in UrlEncode function also does not, urlencode the backslash and other ASCII character also to encode, still can not solve the problem, use the following function can solve this problem.
The simple principle is to convert all byte with byte greater than 127 to 16 binary.
Hyperlink address in Chinese
UTF-8 encoded with the ' Http://ftp.php.cn/PHP video tutorial. rar ';//urlencode result: Echo UrlEncode ($url); http%3a%2f%2fftp1.zdy.co% 2fmovie%2f%e6%88%91%e4%b8%ba%e7%9b%b8%e4%ba%b2%e7%8b%82.rmvb//link_urldecode results: Echo link_urldecode ($url); http:/ /ftp1.zdy.co/movie/%e6%88%91%e4%b8%ba%e7%9b%b8%e4%ba%b2%e7%8b%82.rmvb//link_urldecode functions: Function Link_urldecode ($url) { $uri = '; $cs = Unpack (' c* ', $url); $len = count ($cs); for ($i =1; $i <= $len; $i + +) { $uri. = $cs [$i] > 127? '% '. Strtoupper (Dechex ($cs [$i)): $url {$i-1}; } return $uri;}