PHP html_entity_decode() 函數
PHP html_entity_decode() 是一個字符串函數,用于將 HTML 實體轉換為字符。愛掏網 - it200.com字符串函數 html_entity_decode() 是 htmlentities() 的相反函數。愛掏網 - it200.com
html_entity_decode(string,flags,character-set)
參數 | 描述 | 必填/可選 |
---|---|---|
string | 指定要解碼的字符串 | 必填 |
flags | 指定如何處理引號和使用哪種文檔類型。愛掏網 - it200.com | 可選 |
示例1
<?php
str = '<a ;
echo html_entity_decode(str);
?>
輸出:
JavaTpoint.com
示例2
<?php
print_r (get_html_translation_table(HTML_SPECIALCHARS));
?
輸出:
Array ( ["] => " [&] => & [<] => < [>] => > )
示例3
<?php
str = "Hello PHP : 'E=MC?'";
echo html_entity_decode(str, ENT_COMPAT); // Will only convert double quotes
echo "<br>";
echo html_entity_decode(str, ENT_QUOTES); // Converts double and single quotes
echo "<br>";
echo html_entity_decode(str, ENT_NOQUOTES); // Does not convert any quotes
?>
輸出:
Hello PHP : 'E=MC2'
Hello PHP : 'E=MC2'
Hello PHP : 'E=MC2'
聲明:所有內容來自互聯網搜索結果,不保證100%準確性,僅供參考。如若本站內容侵犯了原著者的合法權益,可聯系我們進行處理。