且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

替换rawurlencode中的实体,即& lt; & gt; & quot;

更新时间:2022-12-04 21:35:16

rawurlencode() 与html-encoding转换无关.它执行URL编码.要解码的匹配函数是 rawurldecode() ,但同样,不是您在这里寻找的东西.

rawurlencode() has nothing to do with converting to/from html-encoding. It performs URL encoding. The matching function to decode is rawurldecode(), but again, that is not what you're looking for here.

<编码是html编码.为此,您需要 html_entity_decode() 解码或 htmlentities() 进行编码.

The < encoding is html-encoding. To handle that, you want html_entity_decode() to decode or htmlentities() to encode.

上述功能的基本用法是:

Basic usage for the above sets of functions is:

$urlEncodedStr  = rawurlencode($str);
$urlDecodedStr  = rawurldecode($str);
$htmlEncodedStr = htmlentities($str);
$htmlDecodedStr = html_entity_decode($str);

要将它们组合在一起,可以进行一些组合:

To combine them together you would do some combination:

$urlEncodedHtmlDecodedStr  = rawurlencode(html_entity_decode($str));