Remove encoding using PHP

前端 未结 3 2065
星月不相逢
星月不相逢 2021-02-13 18:02

I have the following text:

We%27re%20proud%20to%20introduce%20the%20Amazing

I\'d like to remove the encoding using PHP, but using html_en

相关标签:
3条回答
  • 2021-02-13 18:41

    This encoding is called Percent encoding or URL encoding. In PHP you have rawurlencode, rawurldecode for “raw” URL encoding as well as the urlencode and urldecode for the slightly different encoding that is used in the query (rather known as application/x-www-form-urlencoded where the space is encoded with + instead of %20).

    In your case the “raw” URL encoding is used. So try rawurldecode to decode it:

    rawurldecode('We%27re%20proud%20to%20introduce%20the%20Amazing')
    
    0 讨论(0)
  • 2021-02-13 18:45

    %27 and %20 are URL encoded entities.

    You'll want to use use urldecode() to decode this. urlencode() exists as well for encoding URL parameters.

    0 讨论(0)
  • 2021-02-13 18:58
    echo urldecode('We%27re%20proud%20to%20introduce%20the%20Amazing');
    

    This is an url_ecoded string. Use urldecode

    0 讨论(0)
提交回复
热议问题