htmlentities() 函数把字符转换为 HTML 实体|html_entity_decode() 函数把 HTML 实体转换为字符

源码技巧6年前 (2019-11-05)7570

htmlentities() 函数把字符转换为 HTML 实体。
html_entity_decode() 函数把 HTML 实体转换为字符。
例子:
$a = '<div> <p>11111&&222</p></div>';
$b = htmlentities($a);
$c = html_entity_decode($b);
echo $b."\n";
echo $c;
页面输出:
htmlentities输出内容:<div> <p>11111&&222</p></div>
html_entity_decode输出内容:11111&&222

HTML 中有用的字符实体

注释:实体名称对大小写敏感!

显示结果描述实体名称实体编号

空格&nbsp;&#160;
<小于号&lt;&#60;
>大于号&gt;&#62;
&和号&amp;&#38;
"引号&quot;&#34;
'撇号 &apos; (IE不支持)&#39;
分(cent)&cent;&#162;
£镑(pound)&pound;&#163;
¥元(yen)&yen;&#165;
欧元(euro)&euro;&#8364;
§小节&sect;&#167;
©版权(copyright)&copy;&#169;
®注册商标&reg;&#174;
商标&trade;&#8482;
×乘号&times;&#215;
÷除号&divide;&#247;

“htmlentities() 函数把字符转换为 HTML 实体|html_entity_decode() 函数把 HTML 实体转换为字符” 的相关文章

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。