我有以下文字:
We%27re%20proud%20to%20introduce%20the%20Amazing
我想使用 PHP 删除编码,但使用html_entity_decode()
不起作用。
有什么建议么?
echo urldecode('We%27re%20proud%20to%20introduce%20the%20Amazing');
这是一个 url_ecoded 字符串。采用urldecode
这种编码称为百分比编码或 URL 编码。在 PHP 中rawurlencode
,rawurldecode
对于“原始”URL 编码,以及在查询urlencode
中urldecode
使用的稍有不同的编码(称为application/x-www-form-urlencoded,其中空间使用+
而不是编码%20
)。
在您的情况下,使用“原始” URL 编码。所以尝试rawurldecode
解码它:
rawurldecode('We%27re%20proud%20to%20introduce%20the%20Amazing')
%27 和 %20 是 URL 编码的实体。
您需要使用urldecode()来解码它。 urlencode()也存在用于编码 URL 参数。