我在mysql數據中有這麼多特殊字符,而我通過php在xml文件中顯示。如何通過PHP將特殊字符轉換爲html字?
—,”,’,“...etc
我想使用php轉換爲原始單詞。
我在mysql數據中有這麼多特殊字符,而我通過php在xml文件中顯示。如何通過PHP將特殊字符轉換爲html字?
—,”,’,“...etc
我想使用php轉換爲原始單詞。
您正在尋找html_entity_decode
$s = ' —,”,’,“';
echo html_entity_decode($s);
所有你需要的是http://www.php.net/manual/en/function.html-entity-decode.php
使用標籤,我得到XML error..that後是錯誤的第859行的第5行:xmlParseEntityRef:沒有名稱 – user3445862
你應該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
?>
在使用該標記後,我得到了xml錯誤..第859行是第5行的錯誤:xmlParseEntityRef:no name – user3445862
使用標籤,我得到XML error..that後在第5行的錯誤在列859:xmlParseEntityRef:沒有名字 – user3445862