12

我有以下文字:

We%27re%20proud%20to%20introduce%20the%20Amazing

我想使用 PHP 删除编码,但使用html_entity_decode()不起作用。

有什么建议么?

4

3 回答 3

33
echo urldecode('We%27re%20proud%20to%20introduce%20the%20Amazing');

这是一个 url_ecoded 字符串。采用urldecode

于 2010-03-10T16:53:43.173 回答
7

这种编码称为百分比编码或 URL 编码。在 PHP 中rawurlencoderawurldecode对于“原始”URL 编码,以及在查询urlencodeurldecode使用的稍有不同的编码(称为application/x-www-form-urlencoded,其中空间使用+而不是编码%20)。

在您的情况下,使用“原始” URL 编码。所以尝试rawurldecode解码它:

rawurldecode('We%27re%20proud%20to%20introduce%20the%20Amazing')
于 2010-03-10T16:59:25.163 回答
1

%27 和 %20 是 URL 编码的实体。

您需要使用urldecode()来解码它。 urlencode()也存在用于编码 URL 参数。

于 2010-03-10T16:59:13.520 回答