php javascript url encoding

前端 未结 4 393
深忆病人
深忆病人 2020-12-24 12:49

I have a html text. I had encoded it in php using urlencode function. I want to decode that text in the javascript. when i use unescape function in javascript it replaces a

4条回答
  •  一生所求
    2020-12-24 13:10

    Try this:

    return decodeURIComponent((str + '').replace(/\+/g, '%20'));
    

    Source: http://phpjs.org/functions/urldecode:572

提交回复
热议问题