PHP html實體與字元之間的轉換函式

2021-07-24 14:42:14 字數 1018 閱讀 7408

htmlentities()函式htmlentities(string,flags,character-set,double_encode);

定義和用法:htmlentities() 函式把字元轉換為 html 實體。

flags:可用的引號型別:

ent_compat - 預設。僅編碼雙引號。

ent_quotes - 編碼雙引號和單引號。

ent_noquotes - 不編碼任何引號。

html_entity_decode() 函式html_entity_decode(string,flags,character-set)

htmlspecialchars_decode() 函式htmlspecialchars_decode(string,flags)

定義和用法:htmlspecialchars_decode() 函式把預定義的 html 實體轉換為字元。

會被解碼的 html 實體是:

& 解碼成 & (和號)

" 解碼成 " (雙引號)

' 解碼成 ' (單引號)

< 解碼成 < (小於)

> 解碼成 > (大於)

htmlspecialchars_decode() 函式是 htmlspecialchars() 函式的反函式。

htmlspecialchars() 函式htmlspecialchars(string,flags,character-set,double_encode)

定義和用法:htmlspecialchars() 函式把預定義的字元轉換為 html 實體。

預定義的字元是:

& (和號)成為 &

" (雙引號)成為 "

' (單引號)成為 '

< (小於)成為 <

> (大於)成為 >

實體與實體之間的聯絡

單張表的缺點 表的結構不清晰 造成資料冗餘 表的可擴充套件性差 一對多關係 多對多關係 1.修改表的完整語句 1.修改表名 alter table 表名 rename 新錶名 2.增加字段 alter table 表名 add 欄位名 資料型別 完整性約束條件 add 欄位名 資料型別 完整性約束條...

實體類與實體DTO類之間的轉換

通過nuget包管理器新增newtonsoft.json 構造乙個trans的靜態方法 public static tout trans tin tin 前端呼叫 people people new people 構造乙個trans的靜態方法 public static tout trans tin...

XML檔案與實體類之間的互相轉換

config.xml xml version 1.0 encoding utf 8 config xmlns xsi xmlns xsd isauto true description 定時掃瞄資料庫,通過客戶號和業務號讀取客戶資訊 description customerinfos custome...