【发布时间】:2014-03-25 07:27:09
【问题描述】:
当我通过php在xml文件中显示时,我在mysql数据中有很多这样的特殊字符。
—,”,’,“...etc
我想用php转换成原词。
【问题讨论】:
当我通过php在xml文件中显示时,我在mysql数据中有很多这样的特殊字符。
—,”,’,“...etc
我想用php转换成原词。
【问题讨论】:
您正在寻找html_entity_decode
【讨论】:
$s = ' —,”,’,“';
echo html_entity_decode($s);
您只需要http://www.php.net/manual/en/function.html-entity-decode.php
【讨论】:
您应该选择htmlspecialchars_decode,因为html_entity_decode 是一个较轻的版本。
<?php
$s = '—,”,’,“';
echo htmlspecialchars_decode($s);
OUTPUT :
—,”,’,“
【讨论】:
<?php
$orig = "I'll \"walk\" the <b>dog</b> now";
$a = htmlentities($orig);
echo $a; // I'll "walk" the <b>dog</b> now
$b = html_entity_decode($a);
echo $b; // I'll "walk" the <b>dog</b> now
?>
【讨论】: