Loading... # [如何正确的用PHP进行url编码urlencode](https://blog.p2hp.com/archives/5501) ```php <?php function myUrlEncode($string) { $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D'); $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]"); return str_replace($entities, $replacements, rawurlencode($string)); } echo myUrlEncode('http://192.168.8.232/红尘情歌 高安.mp4'); //输出 http://192.168.8.232/%E7%BA%A2%E5%B0%98%E6%83%85%E6%AD%8C%20%E9%AB%98%E5%AE%89.mp4 ``` 最后修改:2023 年 08 月 10 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏