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

被刻印的时光 ゝ 提交于 2019-11-30 06:31:21

问题


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...

I have to do this in php..


回答1:


You should use rawurldecode().
See the Manual




回答2:


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



来源:https://stackoverflow.com/questions/2757911/how-to-decode-the-url-in-php-where-url-is-encoded-with-encodeuricomponent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!