使用 PHP 删除编码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2418771/
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
Remove encoding using PHP
提问by kylex
I have the following text:
我有以下文字:
We%27re%20proud%20to%20introduce%20the%20Amazing
I'd like to remove the encoding using PHP, but using html_entity_decode()does not work.
我想使用 PHP 删除编码,但使用html_entity_decode()不起作用。
Any suggestions?
有什么建议?
回答by erenon
回答by Gumbo
This encoding is called Percent encodingor URL encoding. In PHP you have rawurlencode, rawurldecodefor “raw” URL encoding as well as the urlencodeand urldecodefor the slightly different encoding that is used in the query (rather known as application/x-www-form-urlencodedwhere the space is encoded with +instead of %20).
这种编码称为百分比编码或 URL 编码。在 PHP 中rawurlencode,rawurldecode对于“原始”URL 编码以及urlencode和urldecode用于查询中使用的略有不同的编码(也称为application/x-www-form-urlencoded,其中空格是用+而不是编码的%20)。
In your case the “raw” URL encoding is used. So try rawurldecodeto decode it:
在您的情况下,使用“原始”URL 编码。所以尝试rawurldecode解码它:
rawurldecode('We%27re%20proud%20to%20introduce%20the%20Amazing')
回答by jwhat
%27 and %20 are URL encoded entities.
%27 和 %20 是 URL 编码的实体。
You'll want to use use urldecode()to decode this. urlencode()exists as well for encoding URL parameters.
您需要使用urldecode()来解码它。 urlencode()也用于编码 URL 参数。

