PHP - 将 > 和其他符号转换为文本


PHP - Convert &#62 and other symbols to text

我必须转换这些符号:

  • >
  • &#9996 ;

等。

自:

  • >

我该怎么做?PHP中有任何人可以做到这一点吗?

你可以

使用 PHP 的 html_entity_decode() 函数:

<?php
    $str = "&#62;";
    $str = html_entity_decode($str);
    $str1 = "&#9996;";
    $str1 = html_entity_decode($str1);
?>

更多信息请见 http://php.net/manual/en/function.htmlentities.php。

注意:html_entity_decode()函数与htmlentities()函数相反。

希望这有帮助,谢谢!

<?php
$str = "This is some &lt;b&gt;bold&lt;/b&gt; text.";
 echo htmlspecialchars_decode($str);
 ?>

htmlspecialchars_decode