国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

PHP htmlentities()函數用法講解

2024-05-05 00:06:59
字體:
來源:轉載
供稿:網友

PHP htmlentities() 函數

實例

把一些字符轉換為 HTML 實體:

<?php $str = "<© W3CSçh°°¦§>"; echo htmlentities($str); ?>

上面代碼的 HTML 輸出如下(查看源代碼):

<!DOCTYPE html> <html> <body> <© W3CSçh°°¦§> </body> </html>

上面代碼的瀏覽器輸出如下:

<© W3CSçh°°¦§>

定義和用法

htmlentities()函數把字符轉換為 HTML 實體。

提示: 要把 HTML 實體轉換回字符,請使用 html_entity_decode() 函數。

提示: 請使用 get_html_translation_table() 函數來返回 htmlentities() 使用的翻譯表。

語法

htmlentities( _string,flags,character-set,double_encode_ )

PHP,htmlentities,函數

PHP,htmlentities,函數

實例 1

把一些字符轉換為 HTML 實體:

<?php $str = "Jane & 'Tarzan'"; echo htmlentities($str, ENT_COMPAT); // Will only convert double quotes echo "<br>"; echo htmlentities($str, ENT_QUOTES); // Converts double and single quotes echo "<br>"; echo htmlentities($str, ENT_NOQUOTES); // Does not convert any quotes ?>

上面代碼的 HTML 輸出如下(查看源代碼):

<!DOCTYPE html> <html> <body> Jane & 'Tarzan'<br> Jane & 'Tarzan'<br> Jane & 'Tarzan' </body> </html>

上面代碼的瀏覽器輸出如下:

Jane & 'Tarzan'  
Jane & 'Tarzan'  
Jane & 'Tarzan'

實例 2

通過使用西歐字符集,把一些字符轉換為 HTML 實體:

<?php $str = "My name is Øyvind Åsane. I'm Norwegian."; echo htmlentities($str, ENT_QUOTES, "ISO-8859-1"); // Will only convert doublequotes (not single quotes), and uses the character-set Western European ?>

上面代碼的 HTML 輸出如下(查看源代碼):

<!DOCTYPE html> <html> <body> My name is Øyvind Åsane. I'm Norwegian. </body> </html>

上面代碼的瀏覽器輸出如下:

My name is Øyvind Åsane. I'm Norwegian.

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對VeVb武林網的支持。


注:相關教程知識閱讀請移步到PHP教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 淮阳县| 抚顺市| 奉新县| 玉树县| 牟定县| 兴业县| 乐至县| 佛教| 伊宁市| 临夏市| 兴宁市| 襄垣县| 嵊泗县| 高台县| 杭锦后旗| 岐山县| 神池县| 钟祥市| 巫溪县| 武宁县| 马龙县| 永善县| 得荣县| 佛冈县| 沂源县| 奉贤区| 武邑县| 铜川市| 韶山市| 武川县| 大化| 祁阳县| 闵行区| 三穗县| 海安县| 涿鹿县| 泰兴市| 金秀| 鄂州市| 凤山市| 镇巴县|