我有以下文字:

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 编码以及 urlencodeurldecode 对于查询中使用的略有不同的编码(更称为 应用程序/x-www-form-urlencoded 其中空间编码为 + 代替 %20).

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

rawurldecode('We%27re%20proud%20to%20introduce%20the%20Amazing')

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

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top