21

如何在 php 中解码使用 encodeURIComponent() 编码的 url?

我已经尝试了 urldecode() 但也..我没有我编码的 url ......

我必须在 php..

4

2 回答 2

28

你应该使用rawurldecode().
手册

于 2010-05-03T12:25:36.577 回答
7

你可以使用这个功能:

<?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');
?>

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

于 2013-03-26T13:28:08.597 回答