How to decode the url in php where url is encoded with encodeURIComponent()

前端 未结 2 1892
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 20:22

How to decode the url in php where url is encoded with encodeURIComponent()?

I have tried the urldecode() but then also..i don\'t the url which i have encoded...

相关标签:
2条回答
  • 2020-12-13 20:48

    you can use this function:

    <?php
    $string = 'http%3A%2F%2Fexample.com';
    $output = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($string)); 
    echo html_entity_decode($output,null,'UTF-8');
    ?>
    

    output will be : http://example.com

    0 讨论(0)
  • 2020-12-13 21:04

    You should use rawurldecode().
    See the Manual

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