Javascript 如何在php中解码url,其中url是用encodeURIComponent()编码的

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2757911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 01:48:11  来源:igfitidea点击:

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

phpjavascripturlencodeurldecode

提问by Nitz

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

如何解码 php 中的 url,其中 url 是用 encodeURIComponent() 编码的?

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

我已经尝试过 urldecode() 但后来也......我不知道我编码的 url ......

I have to do this in php..

我必须在 php 中执行此操作..

回答by michal kralik

You should use rawurldecode().
See the Manual

你应该使用rawurldecode().
参见手册

回答by T.Todua

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

输出将是: http://example.com