UTF-8特殊字符输出

时间:2013-11-24 01:34:30

标签: php encoding utf-8 character-encoding special-characters

当我输出某些内容(来自我的utf-8 db)时,如

this "text" is nice

html代码显示

this "text" is nice

如何使用php准确显示撇号"

由于

2 个答案:

答案 0 :(得分:0)

使用函数htmlentities

echo htmlentities('this "text" is nice');

答案 1 :(得分:0)

使用html_entity_decode

从PHP手册:

<?php
 $orig = "I'll \"walk\" the <b>dog</b> now";
 $a = htmlentities($orig);
 $b = html_entity_decode($a);
 echo $a; // I'll &quot;walk&quot; the &lt;b&gt;dog&lt;/b&gt; now
 echo $b; // I'll "walk" the <b>dog</b> now
?>