urlencode only the directory and file names of a URL

后端 未结 5 1826
生来不讨喜
生来不讨喜 2021-02-20 08:18

I need to URL encode just the directory path and file name of a URL using PHP.

So I want to encode something like http://example.com/file name and have it r

5条回答
  •  孤街浪徒
    2021-02-20 08:58

    I think this function ok:

    function newUrlEncode ($url) {
        return str_replace(array('%3A', '%2F'), '/', urlencode($url));
    }
    

提交回复
热议问题