[英]How to convert special characters to html words through 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
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.