PHP - 将HTML符号转换为HTML实体

时间:2017-08-12 19:13:34

标签: php encoding html-entities decoding

$html_str = "Random Text™ First Second Third";

echo $str = html_entity_decode($html_str);

输出:Random Text™First Second Third

现在如何将$ str转换为$ html_str?

1 个答案:

答案 0 :(得分:1)

根据文件: “html_entity_decode()与htmlentities()相反......” http://php.net/manual/en/function.html-entity-decode.php

“htmlentities - 将所有适用的字符转换为HTML实体” http://php.net/manual/en/function.htmlentities.php

您想使用htmlentities

$html_str = htmlentities($str);