函数名 | 释义 | 释义 |
---|---|---|
htmlspecialchars | 将与、单双引号、大于和小于号化成HTML格式 | &转成& “转成”’ 转成’<转成<>转成> |
1.html实体与普通字符串
1.1、htmlspecialchars_decode — 将特殊的 HTML 实体转换回普通字符
string htmlspecialchars_decode ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 ] )
> ==> >
< ==> <
& ==> &
"
1.2、htmlspecialchars — 将特殊字符转换为 HTML 实体
string htmlspecialchars ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = ini_get("default_charset") [, bool $double_encode = TRUE ]]] )
2、使用反斜线转移字符串
2.1、addcslashes — 以 C 语言风格使用反斜线转义字符串中的字符
返回字符串,该字符串在属于参数 charlist 列表中的字符前都加上了反斜线。
string addcslashes ( string $str , string $charlist )
2.2、addslashes — 使用反斜线引用字符串
返回字符串,该字符串为了数据库查询语句等的需要在某些字符前加上了反斜线。这些字符是单引号(’)、双引号(")、反斜线(\)与 NUL(NULL 字符)。
string addslashes ( string $str )
3、反引用字符串转义
stripcslashes() - 反引用一个使用 addcslashes 转义的字符串
stripslashes() - 反引用一个引用字符串