如何正确的用PHP进行url编码urlencode

dafenqi
2023-08-10 / 0 评论 / 14 阅读 / 正在检测是否收录...

如何正确的用PHP进行url编码urlencode

<?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
0

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /www/wwwroot/testblog.58heshihu.com/var/Widget/Archive.php on line 1032

评论 (0)

取消